Welcome! Log In Create A New Profile

Advanced

Two servers, one sign-in page?

Yongtao You via nginx
November 15, 2016 08:44PM
Hi,
I'm new to Nginx. I'm trying to configure Nginx as a reverse proxy to 2 backend services, as follows (see below). The backend1 server is already password protected, but backend2 is not. I'm trying to route backend2 sign-in to backend1 login page. The only thing that is not working is the following scenario:
1. Client tries to access localhost:81/some/resource without signing in first;2. Nginx redirect the client to localhost/login;3. After user signed in, it failed to redirect the user back to localhost:81/some/resource;
It seems the $http_referer is empty. How can I pass the original URL to the sign-in page so that it can redirect back? Here is my configuration:
http: {    upstream backend1 {        server 127.0.0.1:4000;    }
    upstream backend2 {        server 127.0.0..1:5000;    }
    server {        listen 80;
        location / {            proxy_pass http://backend1/;        }
        location = /login {            proxy_pass http://backend1/login;                          proxy_set_header Cookie "redirect_to=$http_referer";        }    }
    server {        listen 81;
        location / {            auth_request /auth-proxy;            error_page 401 =302 http://localhost/login;                          proxy_pass http://backend2/;        }
        location = /auth-proxy {            internal;                          ... ...        }    }}
Can someone please help?
Thanks!Yongtao_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Two servers, one sign-in page?

Yongtao You via nginx November 15, 2016 08:44PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 170
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready