Is there a command that will list all vhosts or servers running under nginx on CentOS? I would like to pipe the results to a text file for reporting purposes.
I'm looking for something similar to this command that I use for Apache:
apachectl -S 2>&1 | grep 'port 80'
Virtual host config files are typically located in the /etc/nginx/sites-available directory. You may also notice that your server has a /etc/nginx/sites-enabled folder, which is where file shortcuts (symbolic links) are placed.
If you are using a dedicated server / VPS and want to host multiple applications on a separate domain and a single server then you will need to host multiple websites on a single server. You can achieve this with Apache / Nginx virtual hosting. Virtual hosting allows you to use a single VPS to host all your domains.
Virtual server selection. Optimization. Compatibility. Server names are defined using the server_name directive and determine which server block is used for a given request. See also “How nginx processes a request”.
Nginx server blocks are located in the /etc/nginx/sites-available directory. The default Nginx server block is /etc/nginx/sites-available/default which serves the default HTML file at /var/www/html/index.
starting from version 1.9.2 you can do:
nginx -T
show complete nginx configuration
nginx -T | grep "server_name " #include the whitespace to exclude non relevant results
show you all server names
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With