【发布时间】:2017-07-25 08:05:31
【问题描述】:
我有一个 NGINX 配置文件,通过开发服务器为网站提供静态文件服务。
静态 -> http://localhost:8080
开发网络服务器 -> http://localhost:8080/dev
还有其他几个服务我绑定到不同的位置指令。
这是配置文件的片段。
...
upstream qgis {
server qgis-spcluster_server:80;
}
...
server {
listen 8080;
server_name localhost;
location / {
root /usr/share/nginx/html/build;
index index.html index.htm;
auth_basic "Zugangskontrolle";
auth_basic_user_file /etc/nginx/.htpasswd;
}
location /dev/ {
proxy_pass http://web_app/;
auth_basic "Zugangskontrolle";
auth_basic_user_file /etc/nginx/.htpasswd;
}
location /static/ {
proxy_pass http://web_app/static/;
}
location /qgis/ {
proxy_pass http://qgis/;
}
location /apex/ {
proxy_pass http://apex/apex/;
auth_basic "off";
}
...
在我打开 URL 以获取静态文件之前,一切都按预期工作。之后,所有其他 URL 都指向静态文件。
- http://localhost:8080/apex -> Apex 服务
- http://localhost:8080 -> 静态网站
- http://localhost:8080/apex -> 静态网站
对我来说,一切看起来都很好,但确实有些问题。
Basic_Auth 产生另一个意外行为。
- http://localhost:8080 -> 基本认证 -> 成功 -> 静态网站
- http://localhost:8080/apex -> 基本身份验证 -> 无法摆脱弹出窗口
所以目前我有点不知道如何解决这个问题。
【问题讨论】:
标签: nginx reverse-proxy nginx-location