Welcome! Log In Create A New Profile

Advanced

Reverse proxy to backend without sending context location to backend

Posted by ogghi 
Reverse proxy to backend without sending context location to backend
June 08, 2018 08:51AM
Hello Nginx community!

I am since a bit of time trying to set up a backend server on my Nginx instance.

I can access the backend directly with: status.domain.com on port 443.

When I add this to my nginx settings:

location /status {
proxy_pass https://status.domain.com/;

}

I would expect it to forward all requests to the status machine.
It doesn't matter if I add trailing slashes in location or proxy_pass directive...

With those settings I get redirected to status.domain.com
I'd like to have all to go through the proxy.

What am I missing here?

Thanks
David
Re: Reverse proxy to backend without sending context location to backend
June 11, 2018 09:31AM
I was trying some more here: this is what I get in access log on nginx:

192.168.0.20 - - [11/Jun/2018:15:25:46 +0200] "GET /status HTTP/1.1" 301 194 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.79 Safari/537.36"
192.168.0.20 - - [11/Jun/2018:15:25:46 +0200] "GET /status HTTP/1.1" 301 194 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.79 Safari/537.36"
192.168.0.20 - - [11/Jun/2018:15:25:46 +0200] "GET /status/ HTTP/1.1" 200 3590 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.79 Safari/537.36"
192.168.0.20 - - [11/Jun/2018:15:25:46 +0200] "GET /build/dist/css/all-2812406e36.css HTTP/1.1" 404 199 "https://services.domain.com/status/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.79 Safari/537.36"
192.168.0.20 - - [11/Jun/2018:15:25:46 +0200] "GET /build/dist/js/all-b2c62d4294.js HTTP/1.1" 404 198 "https://services.domain.com/status/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.79 Safari/537.36"
192.168.0.20 - - [11/Jun/2018:15:25:46 +0200] "GET /build/dist/js/all-b2c62d4294.js HTTP/1.1" 404 198 "https://services.domain.com/status/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.79 Safari/537.36"

I did not find how to set code or quote tags, sorry if I missed this!
Re: Reverse proxy to backend without sending context location to backend
June 21, 2018 09:24AM
location /mylink {
proxy_pass http://10.0.0.2:8000/;
proxy_redirect http://10.0.0.2:8000 /mylink;
port_in_redirect off;
}

This also seems not to work, at least for some specific content.
I will try updating the NGINX version!
Sorry, only registered users may post in this forum.

Click here to login

Online Users

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