default virtual host to catch all domains without a proper match. Thankfully this is as simple as adding the default_server flag to the listen directive. This causes all request without a HOST header or without another vhost matching the HOST header to be sent to this vhost instead. Examples are requests accessing the IP directly or if someone points a random domain at your IP. The server_name _; which you will see mentioned in a lot of guides means nothing and does nothing. It’s just a bogus invalid HOST header that can be used to make sure nothing ever matches it. You should be able to simply not define a server_name.
server {
listen 80 default_server;
server_name _;
index index.html;
root /var/www/default;
}
server {
listen 80 default_server;
server_name _;
index index.html;
root /var/www/default;
}

I am new guy to this job and finding this post is good for me, Thanks and keep sharing like this.web hosting provider
ReplyDelete