【问题标题】:Nginx as proxy : how to exclude specific folder under https but not under httpNginx 作为代理:如何在 https 下但不在 http 下排除特定文件夹
【发布时间】: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 mod-rewrite nginx-config


【解决方案1】:

我发现 Nginx 是代理的唯一解决方案是让 Apache 自己处理重定向。

所以, 一种。 nginx 80 正在重定向到 nginx 443 特定文件夹。 湾。所有 https 都由 nginx 443 重定向到 apache 443,然后在 apache 443 conf 中进行测试,如果是特定文件夹,我停止,否则我重定向到 nginx 80。

它正在工作,但我确信可以让 nginx 处理它并避免这个 1 循环。如果有人作为一个漂亮的答案:-)

【讨论】:

    猜你喜欢
    • 2014-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    • 2017-01-18
    相关资源
    最近更新 更多