1

A server is hosting several website each having its own domain name. Nginx is used the reverse proxy.

When a domain name is pointing to the IP of the server and that no server_name is specified nginx serves a default one that matches with the first configuration file.

I want to avoid this behavior and set on my own the default website nginx should serve.

How can I do this? How can a _default server_name server be chosen when the domain name requested is non-existent.

1

Add the default_server keyword to the listen directive.

server {
    listen 80 default_server;
    ...
}

See this document for more information.

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.