Rewrite URL before passing to proxy Lighttpd

url rewrites won't work in $HTTP["url"]. However, you should be able to rewrite it globally in this manner:

url.rewrite-once = ( "^/wsmobile/video/(.*)" => "/test/" )

and then catch it with:

$HTTP["url"] =~ "^/test/" {

   # do proxy here

}

UPDATE:

Please see here: Lighttpd bug #164. Specifically, proxy-core.rewrite-request should be what you're looking for.


This can be done with proxy.header since lighttpd v 1.4.46. See:

https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModProxy

Example for above would be:

$HTTP["url"] =~ "^/wsmobile/video/" {
proxy.header = ("map-urlpath" => ( "/wsmobile/video" => "/" ))
proxy.server = ( "" => ( ( "host" =>  "210.200.144.26", "port" => 9091 ) ) )
}

One thing I have found though is if you post something on the proxied server (say http://210.200.144.26:9091/post-a-link"), that doesn't get translated properly back to the proxy as it throws a 404 because it's looking for a http://$PROXY/post-a-link not on the server with port 9091.