map $http_x_forwarded_proto $main_proto {
  default $scheme;
  https https;
}



server {
    listen 80;
    listen 443 ssl;
    server_name zscsys.jxau.edu.cn 210.35.129.136;
    ssl_certificate /etc/nginx/include.d/ssl/zscsys.jxau.edu.cn/jxau.crt;
    ssl_certificate_key /etc/nginx/include.d/ssl/zscsys.jxau.edu.cn/jxau.key;


    

    location / {
        proxy_redirect off;
        proxy_pass http://127.0.0.1:8371;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto $main_proto;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
    }
}

server {
    listen 127.0.0.1:8371;

    underscores_in_headers on;
    index index.php index.html index.htm;

    # Uno

    include /etc/nginx/include.d/uno/index.conf;
    include /etc/nginx/include.d/gapper/uno-auth.conf;

    

    include /etc/nginx/include.d/gapper/eyeknow.conf;
    include /etc/nginx/include.d/gapper/apps.conf;
    include /etc/nginx/include.d/gapper/godiva.conf;
    
    
    

    # LabMai
    include /etc/nginx/include.d/labmai-inspection/inspection.conf;include /etc/nginx/include.d/labmai-exam/exam.conf;
    include /etc/nginx/include.d/labmai-standard/standard.conf;
    
    #include /etc/nginx/include.d/labmai-grading/grading.conf;
    #include /etc/nginx/include.d/labmai-hazards/hazards.conf;
    include /etc/nginx/include.d/gapper/grading.conf;
    include /etc/nginx/include.d/gapper/hazards.conf;

    # Misc
    include /etc/nginx/include.d/chacha/dashboard.conf;

    location /locations/mobi {
        alias /var/www/common/room/;
    }

    location /WW_verify_o0D1e2dJoRUVQhV7.txt {
	alias /data/gini-modules/gapper-node/gateway/WW_verify_o0D1e2dJoRUVQhV7.txt;
    }

    # default redirect
    location = / {
        return 302 /labmai/home;
    }

    # for certbot
    location /.well-known {
        root /var/www/certbot;
    }

    # disable .* access
    location ~ /\.(?!well-known|vite) {
        access_log off;
        log_not_found off;
        return 404 'File Not Found';
    }

    # for common dir
    location /common {
        alias /var/www/common;
    }
    #cf 
    include /etc/nginx/include.d/cf/common/reporting.conf;

    location /ping {
        add_header Access-Control-Allow-Origin '*';
        add_header "Content-Type" "text/plain";
        return 200 "pong\n";
    }
}
