首页 > 解决方案 > Nginx auth_request 处理 saml 302 重定向

问题描述

我使用 Nginx 作为反向代理。另外,我正在使用 auth_request 功能来保护我的资源。为此,auth_request 总是通过我使用 SAML 身份验证的授权服务器。在进行身份验证时,有一个重定向 302 到 IDP(在这种情况下为 ssocircle),我试图在 Nginx 上遵循它,但我总是以以下错误结束:

没有定义解析器来解析 idp.ssocircle.com,同时发送到客户端,客户端:127.0.0.1,服务器:,请求:“GET / HTTP/1.1”,子请求:“/saml/login”,主机:“localhost:9000” *1269 身份验证请求意外状态:502 发送到客户端时,客户端:127.0.0.1,服务器:,请求:“GET / HTTP/1.1”,主机:“localhost:9000”

这是我的 Nginx 配置:

server{
    listen 9000 ;

    auth_request /saml/login;
    proxy_intercept_errors on;
    error_page 301 302 307 = @handle_redirects ;

    location /saml/login {
        resolver 46.4.112.4 valid=300s;
        internal;
        proxy_set_header Host $host;
        proxy_pass_request_body off;
        proxy_set_header Content-Length "";

        proxy_pass http://localhost:9090/ ; # url to authorization server

    }

    location @handle_redirects {
        set $saved_redirect_location '$upstream_http_location';
        proxy_pass $saved_redirect_location;

    }

    location / {
        root data/www;
    }
    location /images/ {
        root data/ ;
    }
}

我尝试添加resolver 46.4.112.4ssocircle 的 IP,但没有成功。基本上,我想遵循来自我的授权服务器的重定向,并让用户在 IDP 上进行身份验证并返回到原始 URL。我对 Nginx 很陌生。任何帮助都感激不尽。

编辑:我能够解决上述问题。重新启动 Nginx 对我有用。但我再次收到此错误:

身份验证请求意外状态:发送到客户端时出现 302,

标签: nginxnginx-reverse-proxy

解决方案


推荐阅读