caddy: v2: reverse_proxy "missing port in address"
1. Which version of Caddy are you using (caddy -version)?
512b004332ebf6dfa3fd14269de3cb0031233e34
2. What are you trying to do?
Trying to reverse proxy all requests on a subdomain to an external domain:
link.owenconti.com/XXXXX -> https://redirects.ohseemedia.com/follow
3. What is your Caddyfile?
link.owenconti.com {
reverse_proxy * {
to https://redirects.ohseemedia.com/follow/
transport http {
tls
}
}
}
v1 file (which works):
link.owenconti.com {
proxy / https://redirects.ohseemedia.com/follow/
}
4. How did you run Caddy (give the full command and describe the execution environment)?
Ubuntu, caddy start
7. What did you see instead (give full error messages and/or log)?
Caddy starts fine but when trying to serve a request:
ERROR http.log.error making dial info: upstream https://redirects.ohseemedia.com/follow/: invalid dial address https://redirects.ohseemedia.com/follow/: address /redirects.ohseemedia.com/follow/: missing port in address {"request": {"method": "GET", "uri": "/github", "proto": "HTTP/2.0", "remote_addr": "XXXXX", "host": "link.owenconti.com", "headers": {"Sec-Fetch-Site": ["none"], "Sec-Fetch-Mode": ["navigate"], "Accept-Encoding": ["gzip, deflate, br"], "Accept-Language": ["en-US,en;q=0.9"], "Upgrade-Insecure-Requests": ["1"], "User-Agent": ["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"], "Accept": ["text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3"]}, "tls": {"resumed": false, "version": 772, "resumed": 4865, "proto": "h2", "proto_mutual": true, "server_name": "link.owenconti.com"}}}
8. Why is this a bug, and how do you think this should be fixed?
Works fine in v1, can’t get it working in v2
9. What are you doing to work around the problem in the meantime?
I’m stuck
Bonus: What do you use Caddy for? Why did you choose Caddy?
Trying to use it over nginx, having troubles 😃
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 4
- Comments: 32 (15 by maintainers)
Oh derp, that’s my bad. I had just assumed the shorthand was syntactical sugar for the long form.
{http.request.orig_uri}works perfectly in a caddyfile!Okay, after a lot of trial and error, I finally got it to work. The lambda checks to ensure the host of the incoming request is “redirects.ohseemedia.com”.
When using v1’s proxy feature, the host is set correctly. When using v2’s proxy, the host is not set.
I was able to manually set the Host header to “redirects.ohseemedia.com” in the reverse_proxy.
I’m not sure if there’s a bug or if its working as intended with the v2 proxy?
Either way, thanks @mholt for all of your help, you went much further than you needed to!
Right now in Caddy 2, proxy upstreams have to be network addresses; not URLS.
So:
becomes
However, it’s possible we will make this work more like it does in v1.