Nginx 强制 HTTPS 配置
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /cert/example.com.pem;
ssl_certificate_key /cert/example.com.key;
access_log off;
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:5000;
}
}
server {
listen 80;
server_name example.com;
return 301 https://$server_name$request_uri;
}
注意:需要将 server_name、proxy_pass、ssl_certificate、ssl_certificate_key 改为自己的值。