Forum

Help with localhost virtual host

Praseed
30 August 2011, 20:42
Hiawatha version: 6.14.1
Operating System: Linux 2.6.31.14

Hi Hugo,

It was a great experience using HIawatha.
I'll update my Hiawatha to latest when there is a real need.
Given below is my configuration file.
I'm getting the 405 error response whenever I post the request to www/sgs from the same machine(loopback request).
When I post my request to www/sgs_ssl from a client PC, I'm getting expected response.
Please help me to fix this

Thanks
Praseed

# Hiawatha main configuration file

# GENERAL SETTINGS
ConnectionsTotal = 150
ConnectionsPerIP = 10
SystemLogfile = /home/pvg/hiawatha/log/system.log
GarbageLogfile = /home/pvg/hiawatha/log/garbage.log

# BINDING SETTINGS
#HTTP Port Binding
Binding {
BindingId = HTTP
Port = 80
MaxKeepAlive = 30
TimeForRequest = 3,20
}
#SSL Port Binding
Binding {
BindingId = SSL
Port = 443
SSLcertFile = /home/pvg/hiawatha/ssl_cert/ssl_pub_hiawatha.pem
MaxKeepAlive = 30
TimeForRequest = 3,20
}
#NonSSL localHost SGS Port Binding
Binding {
BindingId = LOCALSGS
Port = 8080
MaxKeepAlive = 30
TimeForRequest = 3,20
}

# COMMON GATEWAY INTERFACE (CGI) SETTINGS
# CGI server on local machine only
#FCGI1 connects to port 2005
FastCGIserver {
FastCGIid = FCGI1
ConnectTo = 127.0.0.1:2005
Extension = fcgi
SessionTimeout = 30
}
# URL TOOLKIT
UrlToolkit {
ToolkitID = to_fcgi
RequestURI isfile Return
Match ^/www/sgs_ssl Rewrite /sgs.fcgi
Match ^/www/sgs Rewrite /sgs.fcgi
}

# DEFAULT WEBSITE
Hostname = 192.168.240.214
WebsiteRoot = /mnt/drivers/webdmn/www/hiawatha/www/server
AccessLogfile = /home/pvg//hiawatha/log/access.log
ErrorLogfile = /home/pvg//hiawatha/log/error.log

# VIRTUAL HOSTS
VirtualHost {
RequiredBinding = LOCALSGS
Hostname = 127.0.0.1
WebsiteRoot = /home/pvg/webdmn/www/hiawatha
UseFastCGI = FCGI1
TimeForCGI = 20
UseToolkit = to_fcgi
}
VirtualHost {
RequiredBinding = HTTP
Hostname = www.ssl.example.net
WebsiteRoot = /home/pvg/webdmn/www/hiawatha/www/server
}
VirtualHost {
RequiredBinding = SSL
Hostname = www.nossl.example.net
WebsiteRoot = /home/pvg/webdmn/www/hiawatha
UseFastCGI = FCGI1
TimeForCGI = 20
UseToolkit = to_fcgi
PasswordFile = digest:/home/pvg/hiawatha/.digest
}

Hugo Leisink
31 August 2011, 07:21
First, the last versions contain several important bugfixes, so it's better to update your webserver.

405 means 'request method not allowed'. Can you look in your access logfile and show me the line with the 405 response?
Praseed
31 August 2011, 16:38
Thanks Hugo.. I'll update my Hiawatha soon
This is the line with 405 response on my access log file
127.0.0.1|Thu 01 Jan 1970 02:08:40 +0000|405|0||POST /www/sgs HTTP/1.1|Host: 127.0.0.1|Accept: */*|Content-Length: 45|Content-Type: application/x-www-form-urlencoded


The virtual host with Required BInding "SSL" is working fine & getting rewrote to "sgs.fcgi" (Match ^/www/sgs_ssl Rewrite /sgs.fcgi), but the one with Required binding "LOCALSGS" is returning 405, looks like "Match ^/www/sgs Rewrite /sgs.fcgi" is not working.
The main diffference between both are
1) "SSL" listens on port 443 & requires SSL certificate
2) "LOCALSGS" listens on port 8080 & doesn't require SSL support (as both server & client in this case is same machine)

Praseed
31 August 2011, 16:40
Posting SSL response too for your reference.
Request sent from external client(Mozilla firefox browser)

192.168.240.2|Thu 01 Jan 1970 00:02:03 +0000|200|270||POST /www/sgs_ssl HTTP/1.1|Host: 192.168.240.214|User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.11) Gecko/20101026 Red Hat/3.6l,application/xml;q=0.9,*/*;q=0.8|Accept-Language: en-us,en;q=0.5|Accept-Encoding: gzip,deflate|Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7|Keep-Alive: 115|Connection: keep-alive|Content-Type/www/sg-test-client-ssl.html|Content-Length: 65|Pragma: no-cache|Cache-Control: no-cache
Hugo Leisink
31 August 2011, 17:55
Please, try this configuration:
# Hiawatha main configuration file

# GENERAL SETTINGS
ConnectionsTotal = 150
ConnectionsPerIP = 10
SystemLogfile = /home/pvg/hiawatha/log/system.log
GarbageLogfile = /home/pvg/hiawatha/log/garbage.log

# BINDING SETTINGS
#HTTP Port Binding
Binding {
BindingId = HTTP
Port = 80
MaxKeepAlive = 30
TimeForRequest = 3,20
}
#SSL Port Binding
Binding {
BindingId = SSL
Port = 443
SSLcertFile = /home/pvg/hiawatha/ssl_cert/ssl_pub_hiawatha.pem
MaxKeepAlive = 30
TimeForRequest = 3,20
}
#NonSSL localHost SGS Port Binding
Binding {
BindingId = LOCALSGS
Port = 8080
MaxKeepAlive = 30
TimeForRequest = 3,20
}

# COMMON GATEWAY INTERFACE (CGI) SETTINGS
# CGI server on local machine only
#FCGI1 connects to port 2005
FastCGIserver {
FastCGIid = FCGI1
ConnectTo = 127.0.0.1:2005
}
# URL TOOLKIT
UrlToolkit {
ToolkitID = to_fcgi
RequestURI isfile Return
Match ^/www/sgs_ssl UseFastCGI FCGI1
Match ^/www/sgs UseFastCGI FCGI1
}

# DEFAULT WEBSITE
Hostname = 192.168.240.214
WebsiteRoot = /mnt/drivers/webdmn/www/hiawatha/www/server
AccessLogfile = /home/pvg//hiawatha/log/access.log
ErrorLogfile = /home/pvg//hiawatha/log/error.log

# VIRTUAL HOSTS
VirtualHost {
RequiredBinding = LOCALSGS
Hostname = 127.0.0.1
WebsiteRoot = /home/pvg/webdmn/www/hiawatha
TimeForCGI = 20
UseToolkit = to_fcgi
}
VirtualHost {
RequiredBinding = HTTP
Hostname = www.ssl.example.net
WebsiteRoot = /home/pvg/webdmn/www/hiawatha/www/server
}
VirtualHost {
RequiredBinding = SSL
Hostname = www.nossl.example.net
WebsiteRoot = /home/pvg/webdmn/www/hiawatha
TimeForCGI = 20
UseToolkit = to_fcgi
PasswordFile = digest:/home/pvg/hiawatha/.digest
}
Praseed
31 August 2011, 19:54
Unfortunately no luck
127.0.0.1|Thu 01 Jan 1970 00:06:57 +0000|405|0||POST /www/sgs HTTP/1.1|Host: 127.0.0.1|Accept: */*|Content-Length: 45|Content-Type: application/x-www-form-urlencoded
Hugo Leisink
1 September 2011, 06:52
Btw, what is it you try to achieve with the separate bindings?
Praseed
1 September 2011, 17:04
Port 80: should allow clients to do file downloads from /home/pvg/webdmn/www/hiawatha/www/server webroot with No SSL
Port 443: Used for all post & get commands which is handled by the fastcgi application using secure SSL conection.
Port 8080: There is a internal client which is running in the same server machine, which needs to access the same fastcgi application.
However as the both the server & client is in the same physical machine, it doesn't make any sense to go through the hassle & overhead of handling the secure connection.
I hope there is any nothing by design in HIawatha which should prevent this setup.
Thanks again for your support & we can resolve this soon.

Regards
Praseed
Hugo Leisink
2 September 2011, 08:20
Oke, in that case you should not forget to bind to the right interface. You can now also use port 80 for LOCALSGS. Try this configuration:
# Hiawatha main configuration file

# GENERAL SETTINGS
ConnectionsTotal = 150
ConnectionsPerIP = 10
SystemLogfile = /home/pvg/hiawatha/log/system.log
GarbageLogfile = /home/pvg/hiawatha/log/garbage.log

# BINDING SETTINGS
#HTTP Port Binding
Binding {
BindingId = HTTP
Port = 80
Interface = 127.0.0.1
MaxKeepAlive = 30
TimeForRequest = 3,20
}
#SSL Port Binding
Binding {
BindingId = SSL
Port = 443
Interface = 192.168.240.214
SSLcertFile = /home/pvg/hiawatha/ssl_cert/ssl_pub_hiawatha.pem
MaxKeepAlive = 30
TimeForRequest = 3,20
}
#NonSSL localHost SGS Port Binding
Binding {
BindingId = LOCALSGS
Port = 80
Interface = 192.168.240.214
MaxKeepAlive = 30
TimeForRequest = 3,20
}

# COMMON GATEWAY INTERFACE (CGI) SETTINGS
# CGI server on local machine only
#FCGI1 connects to port 2005
FastCGIserver {
FastCGIid = FCGI1
ConnectTo = 127.0.0.1:2005
}
# URL TOOLKIT
UrlToolkit {
ToolkitID = to_fcgi
RequestURI isfile Return
Match ^/www/sgs(_ssl)? UseFastCGI FCGI1
}

# DEFAULT WEBSITE
Hostname = 192.168.240.214
WebsiteRoot = /mnt/drivers/webdmn/www/hiawatha/www/server
AccessLogfile = /home/pvg//hiawatha/log/access.log
ErrorLogfile = /home/pvg//hiawatha/log/error.log

# VIRTUAL HOSTS
VirtualHost {
RequiredBinding = LOCALSGS
Hostname = 127.0.0.1
WebsiteRoot = /home/pvg/webdmn/www/hiawatha
TimeForCGI = 20
UseToolkit = to_fcgi
}
VirtualHost {
RequiredBinding = HTTP
Hostname = www.ssl.example.net
WebsiteRoot = /home/pvg/webdmn/www/hiawatha/www/server
}
VirtualHost {
RequiredBinding = SSL
Hostname = www.nossl.example.net
WebsiteRoot = /home/pvg/webdmn/www/hiawatha
TimeForCGI = 20
UseToolkit = to_fcgi
PasswordFile = digest:/home/pvg/hiawatha/.digest
}
This topic has been closed.