Forum

Issue with directory based configuraion for Hiawatha

Praseed
14 August 2009, 01:25
Hi,
I've a Hiawatha setup up & running with FCGI application in the back end.
It is working fine & now I'm trying to configure the Hiawatha to match on URI or directory.
I went through the manual pages, howto & posts on the forum.
I changed my config file according to what I found, still I'm not able to what I want.

My requirement is
1) If the file exists, return that file.
2) If the request URI is http://192.168.1.2/special
redirect/rewrite to test,fcgi
3) If the equest URI is http://192.168.1.2/admin
redirect/rewrite to config.fcgi2

Whenever I try to run http://192.168.1.2/special, its returning 404-Not found
The earlier configuration based only on extension was working for me with no issues.
I'm able to configure & get things done with lighttpd, but I prefer Hiawatha server.

Please help me fix this.

My main stuff in my httpd.conf is as given below.

#BINDING SETTINGS
Binding {
Port = 80
MaxKeepAlive = 30
TimeForRequest = 3,20
}

#FCGI1 connects to port 2005
FastCGIserver {
FastCGIid = FCGI1
ConnectTo = 127.0.0.1:2005
Extension = fcgi
SessionTimeout = 30
}

#FCGI2 connects to port 2006
FastCGIserver {
FastCGIid = FCGI2
ConnectTo = 127.0.0.1:2006
Extension = fcgi2
SessionTimeout = 30
}

# DEFAULT WEBSITE
Hostname = 127.0.0.1
WebsiteRoot = /usr/localvar/www/hiawatha
StartFile = index.html
ShowIndex = yes
AccessLogfile = /usr/local/log/hiawatha/access.log
ErrorLogfile = /usr/local//hiawatha/error.log
#ErrorHandler = 404:/error.cgi

UrlToolkit {
ToolkitID = to_fcgi
RequestURI isfile Return
Match ^/special Rewrite /test.fcgi
Match ^/admin Rewrite /config.fcgi2
}

VirtualHost {
Hostname = 127.0.0.1
WebsiteRoot = /usr/localvar/www/hiawatha
ShowIndex = yes
AccessLogfile = /usr/local/log/hiawatha/access.log
ErrorLogfile = /usr/local/log/hiawatha/error.log
TimeForCGI = 20
UseFastCGI = FCGI1,FCGI2
UseToolkit = to_fcgi
}




Hiawatha version: 6.14
Operating System: RHEL 5
Prit
14 August 2009, 02:46
Hi Praseed,

If the IP number you are trying to use to access your website is 192.168.1.2, then your virtual host has to be configured to use this IP. Otherwise, it will look at the default website.

I used your same configuration and I am getting the results that you wanted. I just changed the Hostname in my VirtualHost configuration to the IP (ex: 192.168.1.2) and added the two servers to my php-fcgi.conf (127.0.0.1:2005 and 127.0.0.1:2006) and restarted php-fcgi. Also, the files config.fcgi2 and test.fcgi have to be present in the directory /usr/localvar/www/hiawatha.

If you have done all these, then it should work. I just tested this.
Hugo Leisink
14 August 2009, 12:40
Another costruction you can try is the usage of the UseFastCGI UrlToolkit option. You might need to upgrade to the latest version for this.

#BINDING SETTINGS
Binding {
Port = 80
MaxKeepAlive = 30
TimeForRequest = 3,20
}

#FCGI1 connects to port 2005
FastCGIserver {
FastCGIid = FCGI1
ConnectTo = 127.0.0.1:2005
SessionTimeout = 30
}

#FCGI2 connects to port 2006
FastCGIserver {
FastCGIid = FCGI2
ConnectTo = 127.0.0.1:2006
SessionTimeout = 30
}

# DEFAULT WEBSITE
Hostname = 127.0.0.1
WebsiteRoot = /usr/localvar/www/hiawatha
StartFile = index.html
ShowIndex = yes
AccessLogfile = /usr/local/log/hiawatha/access.log
ErrorLogfile = /usr/local//hiawatha/error.log
TimeForCGI = 20
UseToolkit = to_fcgi

UrlToolkit {
ToolkitID = to_fcgi
RequestURI isfile Return
Match ^/special UseFastCGI FCGI1
Match ^/admin UseFastCGI FCGI2
}
Prit
14 August 2009, 20:50
Hey Hugo .. this looks interesting. Thanks for sharing. I was not aware of this type of usage.
Praseed
18 August 2009, 02:20
Thanks Hugo & Prit,
I'm using 6.14 & I wish to continue using it instead of 6.16 for some more time.
1)
I'm trying to do a POST method to an extension (like special as I mentioned in the config ), which will be redirected to the corresponding test.fcgi. However after I made the change suggested by Prit, I'm still not able to pass the data(from browser) to the fcgi app properly, I'm getting error 500.
If I use test.fcgi directly from my web page instead of special, I'm receiving the expected result.
2)
BTW in the configuration version which I posted, I don't want to hardcode the Hostname to something like 192.168.0.2 as it will be non-portable. Instead I prefer localhost/127.0.0.1 How can I do that?

VirtualHost {
Hostname = 127.0.0.1
WebsiteRoot = /usr/localvar/www/hiawatha
ShowIndex = yes
AccessLogfile = /usr/local/log/hiawatha/access.log
ErrorLogfile = /usr/local/log/hiawatha/error.log
TimeForCGI = 20
UseFastCGI = FCGI1,FCGI2
UseToolkit = to_fcgi
}


Sorry for the late response, I got hooked up with some other work
Hugo Leisink
18 August 2009, 13:15
1) If you recieve a 500 error, there's probably a message in the error logfile. Are you sure that your FastCGI application works correctly. In other words: you're sure the FastCGI application is not generating the 500 error?

2) The value of the Hostname setting should be equal to the hostname part of the URL. For example, if you want to use the URL http://www.example.com/some_file.txt, the Hostname must be 'www.example.com'.
Praseed
21 August 2009, 18:09
Everything is working as I needed.
Thanks again Hugo & Prit
This topic has been closed.