我正在尝试将 nginx 设置为反向 rpoxy 服务器,位于多个使用基本身份验证进行身份验证的 IIS Web 服务器前面。
(注意 - 这与 nginx providing the auth using a password file 不同 - 它应该只是对浏览器/服务器之间的所有内容进行编码)
它的工作方式不太好 - 但页面上的每个资源(图像/CSS等)都会反复提示进行身份验证。
upstream my_iis_server {
server 192.168.1.10;
}
server {
listen 1.1.1.1:80;
server_name www.example.com;
## send request back to my iis server ##
location / {
proxy_pass http://my_iis_server;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_pass_header Authorization;
proxy_redirect off;
proxy_buffering 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;
}
}
最佳答案
这个确切的情况花了我很长时间才弄清楚,但我猜 OSS 就是这样。这篇文章已经有一年了,所以也许原来的发布者已经弄清楚了,或者放弃了?
无论如何,对我来说问题至少是由以下几件事引起的:
- IIS 期望领域字符串与其发送到 Nginx 的字符串相同,但如果您的 Nginx server_name 正在监听与上游不同的地址,则服务器端 WWW-Authenticate 不会是 IIS 所期望的,并且忽略它。
- 内置 header 模块不会清除其他 WWW-Authenticate header ,特别是有问题的 WWW-Authenticate: Negotiate。使用 headers-more 模块会清除旧的 header ,并添加您告诉它的任何内容。
在此之后,我终于能够通过 Nginx 推送 Sharepoint 2010。
感谢 stackoverflow。
server {
listen 80;
server_name your.site.com;
location / {
proxy_http_version 1.1;
proxy_pass_request_headers on;
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_pass_header Authorization; //This didnt work for me
more_set_input_headers 'Authorization: $http_authorization';
proxy_set_header Accept-Encoding "";
proxy_pass https://sharepoint/;
proxy_redirect default;
#This is what worked for me, but you need the headers-more mod
more_set_headers -s 401 'WWW-Authenticate: Basic realm="intranet.example.com"';
}
}
关于iis - Nginx 反向代理 - 直通基本身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14839712/