Welcome! Log In Create A New Profile

Advanced

Re: Separated reverse proxy for different users

ivy
September 02, 2017 03:53PM
Hi Francis,

Thanks for your reply.
I added default value to map file and replaced "localhost" with 127.0.0.1
So currently the map file looks like:

ivy 10080;
john 10081;
default 65355;

The conf.file looks like:
map $remote_user $rp_port {
include /home/secure/reverse_proxy.map;
}

server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
set $auth_status 100;
server_name localhost;
root /usr/share/nginx/html;
include /etc/nginx/default.d/*.conf;

location / {
try_files $uri $uri/ =404;
auth_basic "restricted content";
auth_basic_user_file "/home/secure/.passwords";
auth_request_set $auth_status $upstream_status;

proxy_pass http://127.0.01:$rp_port
}
}

This gave me following error:
2017/09/02 12:46:32 [error] 26959#26959: *1905 connect() failed (111: Connection refused) while connecting to upstream, client: client_ip, server: ..., request: "POST / HTTP/1.1", upstream: "http://server_ip:10081/", host: "server_ip", referrer: "http://server_ip/"

I added URI in the proxy_pass line:
proxy_pass http://127.0.0.1:$rp_port$uri;
Among many iterative experiments i found that $uri and $request_uri give the same result:
- On plain root request (like: my.site.info) the needed page is loaded.
client_ip - ivy [02/Sep/2017:14:59:43 -0400] "GET / HTTP/1.1" 200 33185 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36" "-"

- However, on request of any sub-location (like: my.site.info/about) the proxy_pass generates redirect to itself.
client_ip - ivy [02/Sep/2017:14:59:47 -0400] "GET /sysinfo/ HTTP/1.1" 404 571 "http://server_ip/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36" "-"

Here (https://www.jethrocarr.com/2013/11/02/nginx-reverse-proxies-and-dns-resolution/) provided number of workarounds with changing upstreams. I tried all of them with the same result as above - sub-locations give error 404.

I'd glad to try more ideas.
Thank you.
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: 99
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready