New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatic HTTP redirect not working if domain block has another value for bind #4738
Comments
The bind address In case you got that from the docs, there was a mistake and it was fixed in caddyserver/website#227. |
Does this also apply for IPv6 addresses too other than localhost; they should be wrapped in brackets? |
Yes, because otherwise the IPv6 colons conflict with the colon for the port number. For example, when you run "listen": [
"127.0.0.1:443",
"::1:443"
], You can pretty clearly see where parsing can go wrong there -- the error saying So with square brackets: "listen": [
"127.0.0.1:443",
"[::1]:443"
], This makes more sense from a parsing perspective. |
Ah, thank you very much! This went unnoticed when I was trying to debug an IPv6 issue in my server. |
I ran into a similar problem with binding IPv6 addresses after upgrading to 2.5.0. The error message is very unclear. It used to work on and before 2.4.6 so I think this is a regression that should be fixed, instead of just changing the docs. |
This was an intended change. See #4532 I agree that the error message is misleading and unclear, though. I'll see if I can improve it to have a "did you mean" in there to suggest using brackets if there's more than one |
#4740 should improve it. My earlier analysis that |
Would it be possible to add a functionality to |
That's probably possible. Actually I'm kind of surprised the brackets are needed when there's no port. Is it normal to write IPv6 addresses with brackets even without ports? |
@mholt in this case, there is a port, cause this is for listener addresses and |
@francislavoie Ah true... but I mean, shouldn't JoinHostPort do that for us? Or maybe we should wrap it for the user. I dunno. Ah, RFC 7239 section 6.1 says:
So, there we have it. I guess the square brackets need to be provided by the user. Yeah, updating our docs should be fine then. |
Already done 😅 caddyserver/website#227 |
After recently updating my Caddy from 2.4.3 to the latest version and restarting the daemon, I kept getting an error in my log:
I thought I had been missing any directives or something else that was removed/deprecated, however I couldn't find anything related to this everywhere else.
I tried setting global options, explicitly enabling automatic HTTPS redirects, but none of that worked. By running
caddy adapt
on my Caddyfile I found out that it only had HTTPS listeners and no HTTP listeners. Then I found out that the default value for thebind
is to bind to all available interfaces, and upon removing the directive from my domain block, the error was gone.Caddyfile for reference:
The text was updated successfully, but these errors were encountered: