Linux, FreeBSD, Juniper, Cisco / Network security articles and troubleshooting guides
https://forum.ivorde.com/

Nginx: How to list virtual hosts
https://forum.ivorde.com/nginx-how-to-list-virtual-hosts-t19775.html
Page 1 of 1

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

Unlike Apache (see https://forum.ivorde.com/apache-how-to-list-virtual-hosts-that-are-currently-configured-on-my-apache-server-t53.html), 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


Code:
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 server1.domain.com;
/etc/nginx/conf.d/server2.conf:        server_name server2.domain.com;


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
http://www.phpbb.com/