Forum

Configuring virtual host on a localhost request

G Caplan
10 April 2012, 18:45
Hi

To run a development tool I need to set up a VirtualHost that will be bound to a localhost request.

As you recommend. I have a standard Default Website:

Hostname = 127.0.0.1
WebsiteRoot = /var/www
StartFile = index.html

To provide an address for the VH I've set up a binding on localhost:

Port = 8090
BindingID = port8090
Interface = 127.0.0.1

Finally, I've configured a VirtualHost with:

Hostname = 127.0.0.1:8090

The problem is that however I set up the Default Website Hostname, it captures all requests to the local binding port8090 so I can't reach the VirtualHost. For example, I tried this:

# Default Website
Hostname = 127.0.0.1:80, 127.0.0.1:433

Sorry if I'm missing something obvious, but I'd appreciate a solution to this!
Hugo Leisink
16 April 2012, 09:18
To find the right virtual host section, Hiawatha does a single string compare with the hostname set in the Hostname option and the one entered in the URL bar. Yes, you can add a port number in the URL bar, but that doesn't make it part of the hostname. So, adding :8090 to the value of the Hostname option causes that it will never match the one entered in the URL bar.

Since you are using only one hostname, namely 127.0.0.1, there is no way to make two host configurations. The first one Hiawatha looks at will match. In your case, simply use one host configuration: the Default Host. Don't use virtual ones, since you don't have any. Use one binding, the port you want to use, and ignor the BindingID and RequiredBinding options.
G Caplan
16 April 2012, 18:29
Thanks Hugo

I'll have to figure out a workaround - not ideal but not a big deal either!
This topic has been closed.