I'm using nginx and I follow a simple tutorial to create vhosts. My problem is that if someone point his DNS to my server, nginx seems to not care about the server_name directive.

I have:

  listen          80;
  server_name     www.domain.com;

I only have ONE vhost. If I set the DNS of example.com to my server, nginx responds with a 200 page! How is it possible? I don't have that vhost configured on my server.

How do I ONLY allow the domains I have configured into server { }?

I'm using nginx version 0.7.67 on Ubuntu Maverick.

migrated from stackoverflow.com Sep 17 '11 at 22:39

This question came from our site for professional and enthusiast programmers.


Is it not like apache and just pick the default (first) configuration? If you don't want people to forward their domain to your server, make two or more virtual hosts, the first one pointing to an error page, and then any request for a domain not hosted by you will return an error.

  • 1
    and make that first vhost a default (listen 80 default;) – sendmoreinfo Feb 3 '12 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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