Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 4 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

http {
  index index.html;

  server {
    access_log logs/domain1.access.log main;

    root /var/www/;

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:

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


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.