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

Nginx: How to list virtual hosts
Page 1 of 1

Author:  mandrei99 [ Mon Feb 23, 2015 5:05 pm ]
Post subject:  Nginx: How to list virtual hosts

Unlike Apache (see, nginx does not have, at the time of this writing, a builtin option to list configured virtual hosts, so in order to lists vhosts in Nginx web server, all nginx configuration files should be checked for the key "server_name" that are not commented (lines begin with #).

How to list virtual hosts configured in NGINX

root@ubuntu-vpsie:~# find /etc/nginx/ -type f -name "*.conf" -print0 | xargs -0 egrep '^(\s|\t)*server_name'
/etc/nginx/conf.d/server1.conf:        server_name;
/etc/nginx/conf.d/server2.conf:        server_name;

Where /etc/nginx is nginx configuration directory and "*.conf" are all configuration files.

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