# HTTP -> HTTPS 强制跳转
server {
    listen 80;
    server_name wk.aionline.cc;
    return 301 https://$host$request_uri;
}

# HTTPS
server {
    listen 443 ssl;
    http2 on;
    server_name wk.aionline.cc;
    root /home/www/pap_web/www;

    ssl_certificate     /etc/nginx/ssl/wk.aionline.cc.pem;
    ssl_certificate_key /etc/nginx/ssl/wk.aionline.cc.key;
    ssl_protocols       TLSv1.2 TLSv1.3;
    ssl_ciphers         HIGH:!aNULL:!MD5;

    set $node_port 8361;

    index index.js index.html index.htm;

    # 静态资源直接返回，长缓存
    location ~ /static/ {
        etag    on;
        expires max;
    }

    # 上传文件目录
    location /upload/ {
        alias /home/www/pap_web/www/upload/;
        etag on;
        expires 7d;
    }

    # 其余请求代理到 Node
    location / {
        proxy_http_version 1.1;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_pass http://127.0.0.1:$node_port;
        proxy_redirect off;
    }
}
