1

When using nginx as a reverse proxy with proxy_pass, which also provides SSL, it appears that most upstream web servers don't even need to know that they are behind a reverse proxy, or that they are accessed over HTTPS rather than HTTP - they just work.

What I'm curious about is this: at what point are hyperlinks changed? If my web server at example.com returns a page with a hyperlink to http://www.example.com/some_page, when it gets to the browser, the hyperlink appears as https://www.example.com/some_page. How does that happen?

My normal setup is to have the upstream server also running nginx, and pass requests to django. I never really thought about it until now. Does the reverse proxy change the hyperlinks? Does the client's browser? Does the upstream nginx server? Does django? What happens if the hyperlink is in a .js file? Is there any chance whatever is changing these hyperlinks messes up, and breaks the code? How would it know that it's a hyperlink, and not just text on the page that I don't want changed?

  • 1
    In many cases you would use /some_page and let the browser work out the scheme and host to use. Also, you can use a protocol-relative URL where the host is different but the scheme should be the same. – Richard Smith Jul 17 at 6:35
  • @RichardSmith Right... I'm an idiot. Hyperlinks don't usually include the domain parts when they are to the same domain as the webserver is on. The browser figures it out. I knew that, but didn't make the connection. If you put that as an answer, I'll mark it answered. Thanks! – Tal Jul 17 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.