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

I'd like to only server requests that are made to a specific domain and just drop everything else or give it 404. Would prefer to see it done through nginx but would of course like the best solution.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

When you setup Nginx, set your "server block" to be specific rather than general. This one would only pick up traffic going to www.domain1.com.

http {
  index index.html;

  server {
    server_name www.domain1.com;
    access_log logs/domain1.access.log main;

    root /var/www/domain1.com/htdocs;
  }
}

Where as this one would pick up all traffic to port 80.

http {
  index index.html;

  server {
    listen 80 default_server;
    server_name _; # This is just an invalid value which will never trigger on a real hostname.
    access_log logs/default.access.log main;

    server_name_in_redirect off;

    root  /var/www/default/htdocs;
  }    
}

More info: http://wiki.nginx.org/ServerBlockExample

share|improve this answer
    
Awesome thanks a lot for the talk through. The default config I copied from had a listen 80; in there and when I removed it everything worked as expected. Thanks again for this! –  mhenrixon Feb 18 '12 at 8:14

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.