Reverse proxy with URI
December 03, 2020 03:15PM
Hello,

I'm new with Nginx and i have some mistake with a configuration.

I use Nginx on CentOS 7.

Here is my configuration :

==========
server {
listen 80;
server_name sub.domain.tld;

location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://10.3.3.2:9595;
}

location /manage/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://10.3.3.1:9595/;
}
}
===========
When i go to my domain, the first location works fine..
But when i go to sub.domain.tld/manage, this is the application on 10.3.3.2 that appears.

And i don't understant why

Someone can help me?

Thank in advance.

Bertrand
Re: Reverse proxy with URI
December 03, 2020 03:21PM
I also try to invert the to location with no success

Bertrand
Re: Reverse proxy with URI
December 03, 2020 03:36PM
Change
location /manage/
in to
location /manage

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: Reverse proxy with URI
December 04, 2020 02:54AM
Hi,

Remove / doesn't change anything. I got the same issue...

i configured a new "server" with a port (9901) for testing like this :

server {
listen 80;
server_name sub.domain.tld 192.168.1.53;
location /manage {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://10.3.3.1:9595;
}
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://10.3.3.2:9595;
}
}

server {
listen 9901;
server_name sub.domain.tld 192.168.1.53;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://10.3.3.1:9595/;
}
}

When i try to get http192.168.1.53:9901 i also get 10.3.3.2 server

It's so crazy....

Bertrand

Edit : and for each test, i delete the cache from my navigator....



Edited 2 time(s). Last edit at 12/04/2020 02:57AM by bertho.
Re: Reverse proxy with URI
December 04, 2020 03:37AM
You may have to enable debug logging to see how each location is handled.
And Curl to see via the headers if the server you think is connected is the same.

ea., proxy_pass http://10.3.3.1:9595/; and take 10.3.3.2 offline.

---
nginx for Windows http://nginx-win.ecsds.eu/
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 143
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready