Nginx auth_request处理SAML 302重定向

时间:2019-09-22 00:46:56

标签: nginx nginx-reverse-proxy

我正在使用Nginx作为反向代理。另外,我正在使用auth_request功能来保护我的资源。为此,auth_request始终通过我使用SAML身份验证的身份验证服务器。进行身份验证时,有一个重定向到IDP的重定向302(在本例中为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”,主机:   “本地主机: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/ ;
    }
}

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

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

  

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

0 个答案:

没有答案