1

So I have what seems to be a seemingly simple problem, but I am very new to this. I have set up a reverse proxy for my development environment, and I have have several machines that run different applications so I have them running on localhost with different ports obviously. Whenever I hit a location say localhost/location1 and localhost/location2 it does a proxy_pass to localhost:8000 and localhost:4343. However, when I hit the root location seen below in my browser the url changes to the actual URL of the proxy_pass https://develop.example.com/; instead of just saying localhost which I would expect it to do like all the others do. So why does this change the URL? I have even tried doing a proxy pass to google which works as expected it just says localhost but shows a google 404 page. Any insights and or suggestions on how I can go about debugging this would be appreciated.

location / { proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-URI $request_uri; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Published-On https://develop.example.com/; proxy_pass https://develop.example.com/; #proxy_pass http://www.google.com/; index index.php; } 
4
  • Could you add the whole server section instead of a single location? Commented Jul 15, 2017 at 5:25
  • Why do you have index and proxy_pass directives? I suggest you edit your question to make it easier to understand, and add your full configuration. Commented Jul 15, 2017 at 5:40
  • 1
    It is most likely that your application is sending a redirect response back to the user, therefore you need to look at your application. Commented Jul 15, 2017 at 5:51
  • URLs containing "localhost" and "reverse proxy" are never a good idea. Commented Jan 16, 2024 at 9:35

1 Answer 1

1

Add a proxy_redirect.

proxy_redirect https://develop.example.com/ /; 

This will rewrite the base url in the output from the proxy_pass so that links, etc., point back to the proxy.

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.