Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unicode domain name in Nginx server_name

Tags:

nginx

punycode

I am trying to set up a server with a domain name called "privatinstruktør.dk" but keeps getting redirected to the default "welcome to nginx" page.

I have tried to type in the server_name like this:

server {
  listen 80;
  server_name privatinstruktør.dk;

  location / {
    root /var/www/privat;
  }
}

but that did not work. So I tried using regular expressions like:

server_name "~^privatinstrukt(.+)r\.dk$";

and

server_name "~^privatinstrukt(.*)r\.dk$";

and even

server_name "~^privat(.*)$";

But all fails and I am redirected to the default page. Does anyone have a hint on how to fix this?

like image 374
Theis Borg Avatar asked Nov 23 '16 12:11

Theis Borg


People also ask

What does server_name _ mean in nginx?

On the other side, server_name _; defines an invalid server names which never intersect with any real name. It is just a non-match. So in the event of no matches, nginx will select the first server{} block and use that. To conclude, you can use server_name _; for catch-all server block but not server_name ""; .

Can domain names be Unicode?

The DNS actually allows any characters in a domain name, and a Unicode name, with a UTF-8 type encoding, would probably be accepted as is by the server, which would confuse applications prompting them to convert it into Punycode. If you register a name with a domain name registry, you will often go through a registrar.

What is $host in nginx?

$http_host contains the content of the HTTP "Host" header field, if it was present in the request. $server_name contains the server_name of the virtual host which processed the request, as it was defined in the nginx configuration.


1 Answers

Configure a Unicode domain name using punycode format in nginx:

server_name xn--privatinstruktr-jub.dk;
like image 124
Alexander Azarov Avatar answered Oct 05 '22 15:10

Alexander Azarov