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 改成本身的值。nginx