0

This config works correctly as expected:

    server {
            listen       80;
            server_name  www.domain1.com domain1.com;

            access_log  /srv/www/domain1.com/logs/access.log;

            location / {
                root   /srv/www/domain1.com/public_html;
                index  index.html index.htm;


    }
    }
    server {
            listen       80;
            server_name  domain2.com www.domain2.com;

            access_log  /srv/www/domain2.com/logs/access.log;

            location / {
                root   /srv/www/domain2.com/public_html;
                index  index.html index.htm;


    }
    }

This config displays the content from domain1 when accessing http://domain2.com:

    server {
            listen       80;
            server_name  *.domain1.com;

            access_log  /srv/www/domain1.com/logs/access.log;

            location / {
                root   /srv/www/domain1.com/public_html;
                index  index.html index.htm;


    }
    }
    server {
            listen       80;
            server_name  *.domain2.com;

            access_log  /srv/www/domain2.com/logs/access.log;

            location / {
                root   /srv/www/domain2.com/public_html;
                index  index.html index.htm;


    }
    }

I feel like I'm following the docs correctly in both cases.

What would cause the unexpected behavior using wildcards in example two?

some1
  • 1,547
  • 8
  • 26
  • 45
  • 1
    delete the asterisk if you want your site to be displayed as http://domain2.com. That means you need to have `server_name .domain1.com;` and `server_name .domain2.com;` – foibs Dec 11 '13 at 23:34

1 Answers1

0

*.domain2.com doesn't match domain2.com. do:

server_name  domain2.com *.domain2.com;

instead

Michael Tabolsky
  • 3,429
  • 2
  • 18
  • 11