ReverseProxy and UrlToolkit in Hiawatha

· klm's blog


Original post is here: eklausmeier.goip.de

This blog uses the Hiawatha web-server. Hiawatha is a lightweight web-server with special focus on security.

Hiawatha offers, among other features, reverse proxy functionality and URL rewriting, see man page. Reverse proxy is configured by keyword ReverseProxy. Multiple reverse proxies may be specified. URL rewriting is configured by using the so called URL toolkit with keyword UrlToolkit. Both features fiddle with the URL.

It seems that UrlToolkit is handled before ReverseProxy. Therefore, if you have some specially designed URLs which need reverse proxy handling then these URLs need to be "escaped" in UrlToolkit.

Example: We want the /admin/ URL act as entry point for our reverse proxy.

 1UrlToolkit {
 2	ToolkitID = ElmarsBlog
 3	RequestURI isfile Return
 4	Match ^/admin Return
 5	Match ^(/*)$ Rewrite /blog/
 6	Match ^([^?&]+)([^/])$ Redirect 301 $1$2/
 7}
 8
 9VirtualHost {
10	Hostname = eklausmeier.goip.de
11	WebsiteRoot = /srv/http
12	UseToolkit = ElmarsBlog
13	UseDirectory = WebPresence
14	ReverseProxy = ^/admin/ 1 http://eklausmeier.goip.de:9999 keep-alive
15}

It is important that the /admin string in UrlToolkit is not closed with a slash.