Linux, FreeBSD, Juniper, Cisco / Network security articles and troubleshooting guides

NGINX: how to set the default virtual host
Page 1 of 1

Author:  mandrei99 [ Thu Dec 12, 2013 6:01 am ]
Post subject:  NGINX: how to set the default virtual host

NGINX uses "listen" and "server_name" directives to define a virtual host. A web server virtual host denotes the part in the configuration that specifies what domain to serve based on the "Host:" attribute in the HTTP/1.1 request header sent by the client (browser).

In some cases, NGINX receives requests on the IP address that it listens for domains that it does not host or the IP address. To serve all these requests from a default virtual host, create another vhost section ("server { }") with following "listen" and "server_name" settings:

server {
listen default_server;
server_name   _;

And use a root directory with a nice 404.html page as index.

Reference: NGINX Server Names

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group