, 1 min read
ReverseProxy and UrlToolkit in Hiawatha
Original post is here eklausmeier.goip.de/blog/2022/03-06-reverseproxy-and-urltoolkit-in-hiawatha.
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.
UrlToolkit {
ToolkitID = ElmarsBlog
RequestURI isfile Return
Match ^/admin Return
Match ^(/*)$ Rewrite /blog/
Match ^([^?&]+)([^/])$ Redirect 301 $1$2/
}
VirtualHost {
Hostname = eklausmeier.goip.de
WebsiteRoot = /srv/http
UseToolkit = ElmarsBlog
UseDirectory = WebPresence
ReverseProxy = ^/admin/ 1 http://eklausmeier.goip.de:9999 keep-alive
}
It is important that the /admin string in UrlToolkit is not closed with a slash.