Apache name-based virtual servers without DNS

apache-2.2configurationvirtualhostwindows 7

I have Apache web server installed on local Windows 7 x64 machine. It has no global DNS name.

In default distribution it has virtual host configured in Apache/conf/extra/httpd-vhosts.conf file.

It has one directive

NameVirtualHost *:80

and multiple directives

<VirtualHost *:80>

with different

ServerName www.domain.tld

Different names are written in hosts file and all pointing to 127.0.0.1.

Unfortunately, virtual hosts do not work. Only first <VirtualHost> tag seems to be active. Nothing said on httpd.exe starting and in error.log.

How to make virtual hosts working here?

EDIT

I see no reason why DNS can be required. GET request contains symbolic name of the site, so, the server has all information to distinguish which virtual host was called.

EDIT 1

I found that virtual hosts DO work (without DNS!). It is a problem with one specific host.

Best Answer

Virtualhosts are configured in the following file : extra/httpd-vhosts.conf

Here is an example on how to configure a Virtual Host

<VirtualHost *:80>
ServerAdmin webmaster@website.com
DocumentRoot "/var/sites/website"
<Directory "/var/sites/website">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny   
    Allow from all
</Directory>

ServerName www.website.com
#ServerAlias www1.website.com
ErrorLog "logs/error_log"
CustomLog "logs/access_log" common
</VirtualHost>

Remember to :

Configure your Normal and Aliasses names on your DNS manager, and remember to include this file on the httpd.conf main directives.

Include conf/extra/httpd-vhosts.conf