nginx http強制跳轉https

1.http強制跳轉https

upstream testa.xxx.com{
     server 127.0.0.1:8081;
}
server {
     server_name testa.xxx.com;
     return 301 https://$server_name$request_uri;
}
server {
     listen 443;
     server_name testa.xxx.com;
     ssl on;
     root html;
     index index.html index.htm;
     ssl_certificate   cert/2559281_testa.xxx.com.pem;
     ssl_certificate_key  cert/2559281_testa.xxx.com.key;
     ssl_session_timeout 5m;
     ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
     ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
     ssl_prefer_server_ciphers on;
     location /{
         proxy_pass http://testa.xxx.com;
     }
 }

2.https強制跳轉http

upstream testa.xxx.com{
    server 127.0.0.1:8081;
}
server {
    server_name testa.xxx.com;
    location /{
        proxy_pass http://testa.xxx.com;
    }
}
server {
    listen 443;
    server_name testa.xxx.com;
    return 301 http://$server_name$request_uri;
}
發佈了96 篇原創文章 · 獲贊 44 · 訪問量 17萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章