Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have one ip number to use, 1.2.3.4 and want to share it with several domains. I have site1.com separate, but the other domains I have a script to display content based on the domain. I've moved to a new server, and I'm using nginx 1.0.6. This worked as desired on the old server with nginx 0.8.54. The problem is all domain names pointed at 1.2.3.4 are always showing site.com (the first server block) instead of falling to the wildcard server block. How can I modify this to work as desired?

server {
    listen 1.2.3.4;
    server_name site.com www.site.com;
    root /home/www/site.com;
    ...
}

server {
    listen 1.2.3.4;
    server_name _;
    root /var/www;
    ...
}
share|improve this question

1 Answer 1

up vote 3 down vote accepted

Either move your fallback server block above the block with specific domains, or change your listen to listen 1.2.3.4 default_server;.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.