Redirect to external site

Vladimir Homutov vl at nginx.com
Tue Oct 2 12:40:48 UTC 2018


On Mon, Oct 01, 2018 at 12:22:59PM -0700, Brian W. wrote:
> I have gotten the ldap setup working with their backend-sample-app.py file
> properly and it displays the hello world message. What I cannot figure out
> is how to redirect it to another url on another machine, as opposed to that
> local page, if auth works. Most of the attempts I have tried lead to a
> blank white page sadly. I tried a simple requests or urllibrequest, as well
> as a selfsend_header with the new url. Has anyone else gotten this to work?
>
> Brian

What happens after you succesfully authenticated user, is controlled by
location where your 'auth_request' directive is written.

In example config, it contains:

location / {
    auth_request /auth-proxy;

    error_page 401 =200 /login;

    proxy_pass http://backend/;
}

i.e. users request is passed to an upstream (backend-sample-app.py application).

If you want instead of proxying, return some redirect (and probably set some
headers with data obtained from authentication), you have to setup nginx
to do it, using appropriate directives.

Please refer to:

http://nginx.org/en/docs/http/ngx_http_auth_request_module.html
http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#return
http://nginx.org/en/docs/http/ngx_http_headers_module.html#add_header


More information about the nginx mailing list