【问题标题】:Multiple authentication together with Nginx proxy多重身份验证与 Nginx 代理一起使用
【发布时间】:2012-08-12 20:48:08
【问题描述】:

我正在尝试在 Nginx 中验证多个位置以及 proxy_pass。 Nginx 配置如下:

server {
    listen       443;
    server_name  example.com;

    location /hg/ {
        rewrite      ^/hg/(.*)$ /$1 break;
        proxy_pass   http://127.0.0.1:8001;

        auth_basic            "hg";
        auth_basic_user_file  hg.htpasswd;

        location /hg/repo1/ {
            auth_basic            "hg-repo1";
            auth_basic_user_file  repo1.htpasswd;
        }

        location /hg/repo2/ {
            auth_basic            "hg-repo2";
            auth_basic_user_file  repo2.htpasswd;
        }
    }
}

身份验证工作正常,但代理在嵌套位置(repo1、repo2)被破坏。似乎 proxy_pass 配置没有被继承。因此,Nginx 返回 404(在 /hg/repo1 和 /hg/repo2 上)。

有什么提示吗?

【问题讨论】:

    标签: mercurial proxy nginx hgweb proxypass


    【解决方案1】:

    您需要为每个 location 块重复 proxy_pass

    此外,没有嵌套location 块的功能。通常它们不会嵌套。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多