0

I am trying to set up a connection between two servers so when one is accessed the client is proxied to the second one.

http { upstream serverConn { server <my.server.ip>; } server { listen 80 default_server; root /usr/share/nginx/html; location /test { proxy_pass http://serverConn/; proxy_set_header Host $upstream_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Host $http_host; } } } 

When a client accesses the server, it is supposed to proxy them to <my.server.ip>, but all of the get requests made on the webpage are looking for files on the server hosting nginx.

The URL that triggers the error

Here is a picture of the request made with the wrong ip, it should be <my.server.ip> instead of 10.XXX.XX.X which is the nginx server. Is there any solution to this? I tried many variations of set_header to no avail.

3
  • 2
    You are only proxying paths that begin with /test but the URL in the photo begins with /static/ Commented Mar 16, 2023 at 19:46
  • Also it's better to simply include the URL as text instead of an image, since images are more likely to expire which makes it difficult for future readers. Commented Mar 16, 2023 at 19:47
  • Does this answer your question? Proxy HTTPS requests to a HTTP backend with NGINX Commented Mar 17, 2023 at 19:54

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.