2012-08-12 36 views
0

我试图在Nginx中与proxy_pass一起验证多个位置。 nginx的配置,那么以下内容:与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(on/hg/repo1和/ hg/repo2)。

任何提示?

回答

1

您需要为每个location块重复proxy_pass

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