Nginx的http请求强制跳转至https
upstream xxxxRS{
server 202.205.xxx.xxx;
}
server {
# http请求通过301强制跳转至https
listen 80;
server_name xxxx.nercoa.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name xxxx.nercoa.com;
ssl_certificate conf.d/ssl/002.xxxx.nercoa.com.pem;
ssl_certificate_key conf.d/ssl/002.xxx.nercoa.com.key;
ssl_session_timeout 5m;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4:!DH:!DHE;
client_max_body_size 1000m;
location / {
proxy_redirect off;
proxy_pass http://xxxxRS;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
评论区