Open slowkow opened 6 years ago
I don't know how to inspect the HTTP headers, but I think that may be one way to solve this problem.
I guess that the Forwarded
header is not set correctly, or perhaps some other header needs to be changed.
If I understand HTTP correctly, then there are 4 HTTP headers to inspect:
User request to Proxy server
Proxy server request to Backend application
Backend application response to Proxy server
Proxy server response to User
It might be useful to directly compare the set of 4 headers in two scenarios:
The golang proxy (as shown above), where behavior is not correct. So, the headers are probably not correct.
A similar Apache or nginx proxy, where behavior is correct. These headers should be correct, and could provide a hint about what to change in the golang proxy.
A correct Apache proxy setup looks like this:
# /etc/apache2/sites-available/example.com.conf
<VirtualHost *:80>
ServerName example.com
Redirect /app /app/
ProxyPass /app/ http://localhost:3838/
ProxyPassReverse /app/ http://localhost:3838/
ProxyPreserveHost On
</VirtualHost>
If you'd like to share any ideas or tips, I'd greatly appreciate it!
Do you know why my localhost is returning 404?
Here's the code:
In contrast, this works perfectly well and the localhost app loads as it is supposed to: