Is there any way to get list of Apache virtual hosts from outside of the server i.e. from another computer by querying the apache server.
3 Answers
Unless somebody implements a script on the server that does so and makes it accessible to you, certainly not - the HTTP protocol itself does not have such capability. Be aware that such a feature would be considered unwanted information disclosure by most admins if it was implemented and active by default. Basically, if you are an admin/developer involved in running the server, you can find out from the configuration; if you are not it is plain and simply none of your business.
From the command line you could use apachectl -S; the output is similar to the below.
$ apachectl -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:443 is a NameVirtualHost
default server virtualhost1 (/etc/httpd/conf.d/virtualhost1:17)
port 443 namevhost virtualhost1 (/etc/httpd/conf.d/virtualhost1:17)
port 443 namevhost virtualhost2 (/etc/httpd/conf.d/virtualhost2:16)
*:80 is a NameVirtualHost
default server virtualdefault (/etc/httpd/conf/httpd.conf:144)
port 80 namevhost virtualdefault (/etc/httpd/conf/httpd.conf:144)
port 80 namevhost virtualhost2 (/etc/httpd/conf.d/virtualhost2:1)