在Nginx中,怎么把http全转发为https

    xiaoxiao2021-04-13  28

    1、将所有的http请求转暖换为带www的https请求 server {   listen [::]:80;   listen 80;   server_name yourdomain.com www.yourdomain.com;   # redirect http to https www   return 301 https://www.yourdomain.com$request_uri; } server {   listen [::]:443 ssl http2;   listen 443 ssl http2;   server_name www.yourdomain.com;   # SSL code   # other code } 2、将不带www的http/htts的请求转换为带www的https请求 server {   listen [::]:80;   listen 80;   server_name yourdomain.com www.yourdomain.com;   # redirect http to https www   return 301 https://www.yourdomain.com$request_uri; } server {   listen [::]:443 ssl http2;   listen 443 ssl http2;   server_name yourdomain.com;   # SSL code   # redirect https non-www to https www   return 301 https://www.yourdomain.com$request_uri; } server {   listen [::]:443 ssl http2;   listen 443 ssl http2;   server_name www.yourdomain.com;   # SSL code   # other code } 3、将带www的http/htts的请求转换为不带www的https请求 server {   listen [::]:80;   listen 80   server_name yourdomain.com www.yourdomain.com;   # redirect http to https non-www   return 301 https://yourdomain.com$request_uri; } server {   listen [::]:443 ssl http2;   listen 443 ssl http2;   server_name www.yourdomain.com;   # SSL code   # redirect https non-www to https www   return 301 https://yourdomain.com$request_uri; } server { listen [::]:443 ssl http2; listen 443 ssl http2;   server_name yourdomain.com;   # SSL code   # Other code }

    转载请注明原文地址: https://ju.6miu.com/read-668844.html

    最新回复(0)