Forrest logo
back to the nginx tool

nginx:hosts:list

List all server names configured in nginx vhosts
$ nginx -T | grep server_name
try on your machine

This command involves piping the output of one command to the input of another command in order to filter and display specific information.

Explanation:

  1. nginx is the command to manage the NGINX web server.
  2. The -T option is used to test the configuration files for syntax errors and prints the parsed configuration to the standard output.
  3. | is a pipe symbol used to redirect the output of the previous command (nginx -T) to the input of the next command (grep server_name).
  4. grep is a command-line utility used to search for specific patterns in a text.
  5. server_name is the pattern that grep will search for in the input provided.

Overall, this command will execute the nginx -T command to fetch the server configuration and then the output will be filtered using grep to display only the lines containing the text "server_name". This can be useful to quickly identify the server names configured in NGINX.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.

Questions that are answered by this command:

  • How to list all nginx vhosts?
back to the nginx tool