Welcome! Log In Create A New Profile

Advanced

Re: Separated reverse proxy for different users

Francis Daly
August 30, 2017 02:10PM
On Fri, Aug 25, 2017 at 06:33:11AM -0400, ivy wrote:

Hi there,

> Therefore, I want to add a map:
> map $remote_user $rp_port {
> include /home/secure/reverse_proxy.map;
> }
>
> The map contains:
> ivy 10080;
> john 10081;
>
> From documentation I understood this should come before server definition.
> Then I tried to replace all "ifs" in server body with:
> proxy_pass http://localhost:$rp_port
>
> This configuration gives following errors:
> 2017/08/25 06:29:38 [error] 26582#26582: *631 invalid port in upstream
> "localhost:", client: ..., server: localhost, request: "GET / HTTP/1.1",
> host: "..."

That is because your map does not have a "default" value, so when
$remote_user is empty or does not match one of your listed names,
$rp_port is empty and your configuration is effectively

proxy_pass http://localhost:;

which is invalid. Simplest fix is to always have a value for $rp_port.

> 2017/08/25 06:29:48 [error] 26582#26582: *632 no resolver defined to resolve
> localhost, client: ..., server: localhost, request: "GET / HTTP/1.1", host:
> "..."

That is because you use a proxy_pass with variables, and this version of
nginx does not try to resolve the hostname at startup, instead resolving
it at processing time -- and you have not defined a resolver. Simplest
fix is to use 127.0.0.1 instead of localhost here.

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Separated reverse proxy for different users

ivy August 25, 2017 06:33AM

Re: Separated reverse proxy for different users

Francis Daly August 30, 2017 02:10PM

Re: Separated reverse proxy for different users

ivy September 02, 2017 03:53PM

Re: Separated reverse proxy for different users

Francis Daly September 03, 2017 05:18AM

Re: Separated reverse proxy for different users

ivy September 15, 2017 01:20PM

Re: Separated reverse proxy for different users

Ish Sookun September 03, 2017 07:20AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 305
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