Skip to content
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

🐛 no forward request for Host header including no-ASCII characters #1392

Open
huiyifyj opened this issue Jan 9, 2025 · 0 comments
Open
Labels
Priority: Normal Minor issue impacting one or more users Type: Bug Something isn't working

Comments

@huiyifyj
Copy link

huiyifyj commented Jan 9, 2025

Describe the bug
400 Bad Request error when using cloudflare tunnel, It seems that the issue is with the Host Header.
Generally, the Host matches url, but the issue is with domain containing non-ASCII characters.

In some HTTP client requests, request.URL.Host is converted to punycode for DNS lookup, but request.Host Header may not (still non-ASCII), it results url mismatch with Host Header.

However, the issue can't be fixed by editing cloudflared source code, it seems that cloudflare edge returning a 400 Bad Request due to Host header mismatch. edge doesn't forward the request to local cloudflared service, because I can't receive any log info under --loglevel debug mode.

The following log is that I mocked request by curl, and the response is 400 Bad Request:

❯ curl https://test.ᱛ.com -I -H "Host: test.ᱛ.com"
HTTP/1.1 400 Bad Request
Server: cloudflare
Date: Thu, 09 Jan 2025 06:49:13 GMT
Content-Type: text/html
Content-Length: 155
Connection: close
CF-RAY: -

If you send punycode domain in Host Header, it will work fine:

❯ curl https://test.ᱛ.com -I -H "Host: test.xn--02f.com"
HTTP/1.1 404 Not Found
Date: Thu, 09 Jan 2025 06:49:02 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
x-request-id: d30a13bb-6572-47e6-b197-07c6bb232030
cf-cache-status: DYNAMIC
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=t4Az5lZMh95U6wdaj3GiYWSWukrIWOhMdYeu9TxgiBE2%2F0hoRn6g2PViR1xWwKG5AeMmM64erU8DpXcX6fUHXHK9wOAYcGRO8EibbcIN558%2FHqaDWn0%2FekRkI4N6DFk0LIKh"}],"group":"cf-nel","max_age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Server: cloudflare
CF-RAY: 8ff27c2e7d68658e-SIN
alt-svc: h3=":443"; ma=86400
server-timing: cfL4;desc="?proto=TCP&rtt=4790&min_rtt=3257&rtt_var=2316&sent=4&recv=5&lost=0&retrans=0&sent_bytes=2704&recv_bytes=479&delivery_rate=889161&cwnd=242&unsent_bytes=0&cid=e1431823fd76aa9c&ts=238&x=0"

To Reproduce
Steps to reproduce the behavior:

  1. Configure '...'
  2. Run '....'
  3. See error

Environment and versions

  • OS: Windows
  • Architecture: AMD
  • Version: 2025.1.0
@huiyifyj huiyifyj added Priority: Normal Minor issue impacting one or more users Type: Bug Something isn't working labels Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Normal Minor issue impacting one or more users Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant