Score:0

Nginx sets HTTP_HOST to punycode

no flag

I have a unicode domain name. It is configured as punycode in the server_name directive.

When I call $_SERVER['HTTP_HOST'] in my PHP code, I get that same punycode version. How do I configure Nginx to set HTTP_HOST to the unicode value instead?

As a hotfix, I call idn_to_utf8($_SERVER['HTTP_HOST'], 0, INTL_IDNA_VARIANT_UTS46) at the top of my script. But I would like this to be done automatically outside of my website code.

Closest I found is IDN and HTTP_HOST but it's 10 years old and for Apache.

Score:0
us flag

I don't think there is any support for different character sets in the FastCGI interface, that is used between nginx and PHP.

Therefore even if nginx was able to decode the domain name into UTF-8, there wouldn't be a way to for it to send it properly to PHP.

Your best bet is to add the decoding of HTTP_HOST header into your front controller.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.