0

The following Nginx (v 1.2.1) configuration

server {
    listen 80;
    server_name aaa.example.com;
    root /var/www/aaa;
}

server {

    listen 80;
    server_name hello-world.example.com;
    root /var/www/hello;
}

because the server_name of the second server contains a dash (-), nginx will always open the second server (whether you go to hello-world.example.com or aaa.example.com)

I fixed it by renaming hello-world to helloworld (removing the dash fixed the issue).

Isn't this a bug in Nginx?

boleslaw.smialy
  • 146
  • 1
  • 7
Jad Joubran
  • 160
  • 2
  • 9

1 Answers1

3

This is a bit far-fetched, but try adding this line inside the http context in nginx config:

server_names_hash_bucket_size 64;

Then restart nginx and see if the name with - works.

Janne Pikkarainen
  • 31,852
  • 4
  • 58
  • 81