【发布时间】:2011-12-23 07:21:50
【问题描述】:
我很困惑。
我有一个服务器,它主要通过 ssl 运行 couchdb(使用 nginx 代理 ssl 连接),但还必须提供一些 apache 的东西。
基本上,我希望将不启动 /www 的所有内容发送到 couchdb 后端。如果一个 url 以 /www 开头,那么它应该映射到本地 apache 服务器的 8080 端口。
我的下面的配置可以正常工作,但也会提示我在 /www 路径上进行身份验证。我比 nginx 更习惯于配置 Apache,所以我怀疑我误解了一些东西,但如果有人能从我的配置中看出什么问题(如下),我将不胜感激。
澄清我的使用场景;
- https://my-domain.com/www/script.cgi 应该被代理到 http://localhost:8080/script.cgi
- https://my-domain.com/anythingelse 应该被代理到 http://localhost:5984/anythingelse
只有第二个需要身份验证。导致问题的是身份验证问题 - 正如我所提到的,我也在 https://my-domain.com/www/anything 上受到挑战:-(
这是配置,感谢您的任何见解。
server {
listen 443;
ssl on;
# Any url starting /www needs to be mapped to the root
# of the back end application server on 8080
location ^~ /www/ {
proxy_pass http://localhost:8080/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# Everything else has to be sent to the couchdb server running on
# port 5984 and for security, this is protected with auth_basic
# authentication.
location / {
auth_basic "Restricted";
auth_basic_user_file /path-to-passwords;
proxy_pass http://localhost:5984;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Ssl on;
}
}
【问题讨论】:
标签: authentication configuration proxy nginx location