caddyserver / caddy

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
https://caddyserver.com
Apache License 2.0
55.45k stars 3.91k forks source link

Question about punycode/internationalized domains #6404

Closed nonk123 closed 1 week ago

nonk123 commented 1 week ago

Spent 3 days banging my head on the wall while figuring this out, but the solution was so simple.

I tried this in my Caddyfile:

https://подработка-павлово.рф {
    reverse_proxy docker_container:8000
}

This always got me a 0-byte response whenever I opened the link in my browser.

Then I changed it to punycode:

https://xn----7sbabcjaj0doydgbbik3b.xn--p1ai {
    reverse_proxy docker_container:8000
}

And voila! Everything works.

Was I missing something? I haven't seen any mention of internationalized domains being unsupported in the docs.

Perhaps it should be pointed out more clearly? Or even better: support these by default?

mholt commented 1 week ago

They should be supported. Let's fix this.

mholt commented 1 week ago

I remembered to handle this for CertMagic, so that's fine; but the host matcher does a literal string comparison. We probably need to convert IDNs to their punycode equivalents since that's what clients send even if you input an IDN to them.

mholt commented 1 week ago

Fixed in 99dcdf7e426f0dcbdffe510f241ae8a4fd5a56e6 -- kind of surprised this hasn't come up before. :man_shrugging: Thanks for the issue!