# ---------------------------------------------------------------------------
|
# 示例:Board 为 ASP.NET(Kestrel :3000,PathBase=/board),且使用 Negotiate/Windows 集成一键登录
|
# 与 board.conf 行为一致(80 入口、/board 直连 Board、其它路径 auth_request + DataEase),
|
# 仅在 /board/ 反代段增加与 SPNEGO/NTLM 相关的头与连接行为,便于浏览器与上游完成握手。
|
#
|
# 用法:复制为独立 conf(如 /etc/nginx/conf.d/board-negotiate.conf),勿覆盖现有 board.conf。
|
# 根据环境修改 server_name、upstream 地址与端口。
|
#
|
# 限制说明:
|
# - Negotiate/NTLM 对「连接亲和」敏感;经 nginx 反代时,部分客户端需多次往返。
|
# - 完全「无弹窗」依赖域/Kerberos/浏览器策略;非域机器可能仍出现凭据提示或失败。
|
# - 若一键登录仍异常,可改为 Board 仅由 IIS 托管(IIS 终结 Windows 身份),nginx 只反代到 IIS。
|
# ---------------------------------------------------------------------------
|
|
upstream board_app {
|
server 127.0.0.1:3000;
|
}
|
|
upstream dataease_upstream {
|
server 127.0.0.1:8100;
|
}
|
|
server {
|
listen 80;
|
server_name 192.168.0.235;
|
|
location = /board {
|
return 302 $scheme://$http_host/board/;
|
}
|
|
# Board:反代到 ASP.NET,并透传 Authorization(Negotiate/NTLM),避免被 nginx 吞掉
|
location ^~ /board/ {
|
proxy_pass http://board_app;
|
proxy_http_version 1.1;
|
|
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-Proto $scheme;
|
|
proxy_set_header Authorization $http_authorization;
|
# 部分环境下上游会回传 Negotiate 质询,需原样带回客户端
|
proxy_pass_header WWW-Authenticate;
|
|
# 与部分 NTLM 客户端兼容:保持到上游的连接(按环境可配合 upstream keepalive)
|
proxy_set_header Connection "";
|
|
proxy_connect_timeout 60s;
|
proxy_send_timeout 60s;
|
proxy_read_timeout 60s;
|
}
|
|
location = /internal/board_check {
|
internal;
|
proxy_pass http://board_app/board/check/;
|
proxy_pass_request_body off;
|
proxy_set_header Content-Length "";
|
proxy_set_header Host $host;
|
proxy_set_header X-Original-URI $request_uri;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header Cookie $http_cookie;
|
}
|
|
location / {
|
auth_request /internal/board_check;
|
error_page 401 = @board_need_login;
|
error_page 403 = @board_need_login;
|
|
proxy_pass http://dataease_upstream;
|
proxy_intercept_errors on;
|
|
proxy_http_version 1.1;
|
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-Proto $scheme;
|
|
proxy_redirect http://127.0.0.1:8100/ /;
|
}
|
|
location @board_need_login {
|
return 302 $scheme://$http_host/board/login?next=$request_uri;
|
}
|
}
|