帮助中心

我们将为您提供完善的帮助文档,竭诚为您提供最优质的服务!

Nginx自动跳转到HTTPS

修改Nginx配置文件

示例一

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.exampledemo.com') {
set $redirect_https "${redirect_https}3";
}
if ($http_host = 'exampledemo.com') {
set $redirect_https "${redirect_https}3";
}
if ($redirect_https = "123") {
rewrite ^(.*)$ https://$host$1 permanent;
}

配置示例 配置示例:

server {
listen 80;
server_name www.exampledemo.cn;
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.exampledemo.cn;
server_tokens off;
location / {
fastcgi_param HTTPS on;
fastcgi_param HTTP_SCHEME https;
}
}

以上是否解决了您的问题
  


Copyright © 2006-2022 9557.com. All Rights Reserved. 三千尺科技版权所有 常年律师顾问: 福建瀛坤律师事务所