Nginx 自動跳轉到HTTPS Nginx設置http自動跳轉https SSL配置
站在用戶的角度思考問題,與客戶深入溝通,找到曲松網(wǎng)站設計與曲松網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設計與互聯(lián)網(wǎng)技術結合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:做網(wǎng)站、成都做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣、申請域名、虛擬主機、企業(yè)郵箱。業(yè)務覆蓋曲松地區(qū)。
方法一
rewrite ^(.*)$ https://$host$1 permanent;
方法二
適用于 80端口和443 配置在同一個 server{}內
if ($server_port = 80) {
rewrite ^(.*)$ https://$host$1 permanent;
}
其他情況, 站點綁定很多域名,只讓某個域名跳轉:
set $redirect_https 1;
if ($server_port = 80) {
set $redirect_https "${redirect_https}2";
}
if ($http_host = 'www.yourdomain.com') {
set $redirect_https "${redirect_https}3";
}
if ($http_host = 'yourdomain.com') {
set $redirect_https "${redirect_https}3";
}
if ($redirect_https = "123") {
rewrite ^(.*)$ https://$host$1 permanent;
}
示例
server {
listen 80;
server_name www.getssl.cc;
rewrite ^ https://$http_host$request_uri? permanent;
}
server {
listen 443;
ssl on;
ssl_certificate /etc/ssl/cacert.pem;
ssl_certificate_key /etc/ssl/privkey.pem;
server_name www.yourdomain.com;
server_tokens off;
location / {
fastcgi_param HTTPS on;
fastcgi_param HTTP_SCHEME https;
}
}
分享題目:Nginx自動跳轉到HTTPSNginx設置http自動跳轉httpsSSL配置
新聞來源:http://muchs.cn/article10/ejhjgo.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供面包屑導航、定制開發(fā)、網(wǎng)站排名、響應式網(wǎng)站、網(wǎng)站收錄、用戶體驗
聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)