# HTTP -> HTTPS 强制跳转 server { listen 80; server_name cytx.csybhelp.com; # ACME HTTP-01 验证路径放行 location /.well-known/acme-challenge/ { root /home/acme-challenge; } # HTTP 跳转 HTTPS location / { rewrite ^(.*)$ https://$server_name$1 permanent; } } # HTTPS server { listen 443 ssl; http2 on; server_name cytx.csybhelp.com; root /home/www/cytx_api; access_log /home/wwwlogs/cytx_api_access.log; error_log /home/wwwlogs/cytx_api_error.log; ssl_certificate cert/cytx_csybhelp_com_fullchain.pem; ssl_certificate_key cert/cytx_csybhelp_com_privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers HIGH:!aNULL:!MD5; set $node_port 8361; index index.js index.html index.htm; # 静态资源直接返回,长缓存 location /static/ { root /home/www/cytx_api/www; etag on; expires max; } # 上传文件目录 location /upload/ { alias /home/www/cytx_api/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; } }