Nginx to catch all unhandled vhosts

Sometimes we have to set up access to our web server without any domain name. An example can be a situation when we don’t have it yet. Another situation can be when we want to have a default webpage for any request to the unsupported domain on our server. When we have an Nginx web server, we have to add a few words to the config file. Below show an example of the smallest vhost config.

server {
listen 80 default_server;
server_name _;
root /usr/share/nginx;
}

The most important is „default_server” next to „listen 80” and „_” as server_name value.

That’s all. Please restart Nginx and have fun 🙂

Dodaj komentarz