caddy: Proxy does not pass hostname / port info to the upstream.
Caddyfile:
https://www.waitlisted.dev {
proxy / http://www.waitlisted.dev:3000/
tls wldev.cert wldev.key
}
Expected Behavior:
In my rails applicaiton i would expect my request.host, request.scheme and request.port to be that of the browser.
ex. www.waitlisted.dev, https and 443
Actual Behavoir
My rails app sees the request as its proxied meaning the request headers are being changed by the proxy.
So i get back localhost, http and 80
If anything is unclear i can help clear it up.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 1
- Comments: 16 (7 by maintainers)
Just for interest sake and documentation, I ended up setting these headers which I found in my default Nginx
Are there any docs for
transparent? It should useX-Forwarded-Forinstead ofX-Real-IP, since it is the defined standard:Also, the
{host}placeholder is actuallyyourhost:2015when running as:2015, which causes problems for any HTTP server downstream if using the config presented here.Seems there is no clean solution with the placeholders either, since
{hostname}is the server hostname, not the request one. Would be nice to have a placeholder{just-the-request-hostname-without-port}to solve this without lots of copy-paste.@cederberg @wenerme Caddy 0.9 beta has a
{hostonly}placeholder that replaces with only the host portion of the Host value.Also the docs for
transparentwill land with the release of Caddy 0.9. They’re already pushed to the repo, just not in production yet.As for X-Real-IP please open a new issue about that so we won’t lose track of the discussion. Thanks!
@andreynering We just merged a PR for a preset called
transparentyou can use to set all 3 at once very easily. Not everyone wants these headers set this way.