侧边栏壁纸
博主头像
WinJay博主等级

博观而约取 厚积而薄发

  • 累计撰写 319 篇文章
  • 累计创建 169 个标签
  • 累计收到 1 条评论
隐藏侧边栏

Nginx的http请求强制跳转至https

WinJay
2021-12-21 / 0 评论 / 0 点赞 / 52 阅读 / 882 字 / 正在检测是否收录...
温馨提示:
本文最后更新于 2021-12-21,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

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;
    }
}

0

评论区