【发布时间】:2019-10-12 08:56:32
【问题描述】:
我可以将一些特定的 http 文件夹重写为 https 文件夹,但除了这些特定的文件夹从 https 到 http 之外,我无法重写所有 https;我被困在一个循环中
使用 NGinx 1.12 作为代理,同时处理 http 和 https
我有一个服务器部分来处理 http 80 和一个服务器部分来处理 https(我知道它们可以在同一个部分中)。
他们都是这样开始的
location / {
proxy_pass
server {
listen 80;
我有
location ~ ^/(xxx|yyy|zzz)/.*$ {
rewrite ^ https://www.example.com$uri permanent;
}
并且每当我在 http 中时,它都会重定向到 xxx、yyy 和 zzz 文件夹的 https。到目前为止,一切顺利。
但在server {
listen 443 ssl;
,我想将除 xxx,yyy,zzz 文件夹之外的所有内容重定向到 http。
我确实尝试在 https 部分进行相反的操作,意思是:
location / {
rewrite ^ http://www.example.com$uri permanent;
}
和
location ~ ^/(xxx|yyy|zzz)/.*$ {
#do nothing
}
但它不起作用,我得到一个 404 错误或循环
【问题讨论】:
-
我的链接在文档中对我没有帮助 nginx.org/en/docs/http/configuring_https_servers.html
标签: nginx mod-rewrite nginx-config