阿里云SLB http强制跳转https重定向循环

SLB https 配置

这里可以参考阿里云的官方文档进行配置
https://help.aliyun.com/knowledge_detail/39472.html

注意

官方文档推荐的是后端协议使用HTTP监听80端口,如果要http强制跳转https 会出现重定向循环。
image

这里需要把后端协议端口修改成443,就不会出现重定向循环。

image

nginx 配置 http 强制跳转 https

nginx配置,不需要配置SSL证书,因为这一步SLB已经帮你做了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
server {
listen 443;
server_name www.domain.com;
root html;

}

server {
listen 80;
server_name www.domain.com;
root html;
rewrite (.*)$ https://$server_name$1 permanent;

}

参考:

https://ywwd.net/read-1095

https://help.aliyun.com/knowledge_detail/39472.html

坚持原创技术分享,您的支持将鼓励我继续创作!