5

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.

mhenrixon
  • 153
  • 1
  • 1
  • 5

1 Answers1

5

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

Robert
  • 511
  • 5
  • 14
  • 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 08:14