求助 nginx 的 rewrite,需求是把 http 流量转到 https

发布于 2022-11-14 22:40:57

网上搜到这样一句:

	rewrite ^(.*)$  https://$host$1 permanent;

但是出现了循环重定向

因为用的是 xinnet 的虚拟主机,rewrite 不能指定写在 80 端口下,所以导致 https 也重定向

哪位大佬能帮忙写一个,判断 scheme 是 http://时,重定向到 https://

Questioner
qinrui
Viewed
0
4 个回答
clickhouse 2022-11-14 22:46:22
Yourshell 2022-11-14 22:55:17
https://serverfault.com/a/710062
qinrui 2022-11-14 22:57:44
@clickhouse
@Yourshell
谢谢两位,但受限于 xinnet 的虚拟主机的功能,我只能写一句 rewrite 开头的命令,而且不能指定是在 80 下,还是 443 下,所以两位给的方法不适用
adoal 2022-11-14 23:28:19
既然是这个垃圾 xinnet 的沙雕限制,那就去问它家客服呗。网友又不能突破这种人为的沙雕限制。