Forum

How to set different sites by port

Pedja
13 October 2010, 21:20
Hiawatha version: 7.3
Operating System: Windows XP

I am setting up local web server. I do not use mnemonic addresses as I do not need them. What I want to achieve is to set different sites on different ports. Main site would be on port 80, and additional site on port 1080.

I cannot find way to achieve this. No matter what I do, main site gets connections for both ports.

Here is my config (which does not work as I want it to):

# Hiawatha httpd.conf 
#

Binding {
BindingID = port80
Port = 80
MaxKeepAlive = 30
TimeForRequest = 3,20
}

Binding {
BindingID = port1080
Port = 1080
MaxKeepAlive = 30
TimeForRequest = 3,20
}


ConnectionsTotal = 550
ConnectionsPerIP = 50
SystemLogfile = C:\Program Files\Hiawatha\log\system.log

Hostname = 127.0.0.1
WebsiteRoot = C:\wwwroot
StartFile = index.html
AccessLogfile = C:\Program Files\Hiawatha\log\access80.log
ErrorLogfile = C:\Program Files\Hiawatha\log\error80.log
#ExecuteCGI = yes
#UseFastCGI = PHP5
#TimeForCGI = 10

VirtualHost{
Hostname = 127.0.0.1
RequiredBinding = port80
WebsiteRoot = C:\wwwroot
StartFile = index.html
AccessLogfile = C:\Program Files\Hiawatha\log\access80.log
ErrorLogfile = C:\Program Files\Hiawatha\log\error80.log
}


VirtualHost{
Hostname = 127.0.0.1
RequiredBinding = port1080
WebsiteRoot = C:\wwwroot1080
StartFile = index.html
AccessLogfile = C:\Program Files\Hiawatha\log\access1080.log
ErrorLogfile = C:\Program Files\Hiawatha\log\error1080.log
}

Hugo Leisink
13 October 2010, 22:07
Try giving the two virtualhosts a different hostname then you gave to your default host.
Pedja
27 October 2010, 09:01
Problem is, server can be accessed only by IP address. I cannot use different hostnames. The only way to make different sites to work is to assign them different ports.

I managed this by setting php script on default host which then checks used port and displayed contents accordingly, but for some reason PHP halts frequently, so I would like to be able to simplify things by just displaying HTML, as that is all I need.
Hugo Leisink
27 October 2010, 09:37
Try using a bogus name for the default host. Any random name will do, as long as it is not the same as the hostname for the virtual hosts.
Pedja
29 October 2010, 12:38
I manged to make it work.

I had to set exact IP address in VirtualHost's HostName. As I have several IP's for the server, and I did not bind to single IP I expected it to accept connections on all IP's. That is not the case. It accepts connection only on address specified in HostName.

So, if one wants to accepts connections to several IP's belonging to the same host, he must set VirtualHost for each IP.

Hugo Leisink
29 October 2010, 16:53
That's good to hear.
This topic has been closed.