7

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?

Alexander Azarov
  • 12,971
  • 2
  • 50
  • 54
Theis Borg
  • 378
  • 4
  • 16

2 Answers2

10

Configure a Unicode domain name using punycode format in nginx:

server_name xn--privatinstruktr-jub.dk;
Phil
  • 1,996
  • 1
  • 19
  • 26
Alexander Azarov
  • 12,971
  • 2
  • 50
  • 54
  • 1
    Do you really need both? – Phil Apr 10 '17 at 14:58
  • 4
    @Phil no, the [nginx docs](http://nginx.org/en/docs/http/server_names.html#idn) have specifically this to say: "Internationalized domain names (IDNs) should be specified using an ASCII (Punycode) representation in the server_name directive." – Amunak Jan 06 '20 at 17:57
3

Use only the Punycode name:

server {
  listen 80;
  server_name xn--privatinstruktr-jub.dk;

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

which is what the Nginx Docs say:

Internationalized domain names (IDNs) should be specified using an ASCII (Punycode) representation in the server_name directive

Amunak
  • 456
  • 5
  • 19