Radicale icon indicating copy to clipboard operation
Radicale copied to clipboard

Add reverse proxy example for lighttpd

Open bobrippling opened this issue 4 years ago • 2 comments

Took a bit of tweaking to get the right config, particularly the url rewrite. Hence publishing this for others to see.

bobrippling avatar Apr 18 '21 19:04 bobrippling

Note that this does not work with the current radicale 3.x.

Since "map-urlpath" of lighttpd maps in both directions, redirects from radicale result in a wrong url: Trying to open "https://www.example.com/radicale/" in a browser results in "https://www.example.com/radicale/radicale/.web" (/radicale/ --lighttpd--> / --radicale--> /radicale/.web --lighttpd--> /radicale/radicale/.web), which leads to 404/403-like errors.

Workaround: Remove the doubled path by rewrite:

server.modules += ( "mod_rewrite" )
url.rewrite-once = ( "^/radicale/radicale/(.*)" => "/radicale/$1" )

Complete example:

server.modules += ( "mod_proxy" , "mod_setenv", "mod_rewrite" )
$HTTP["url"] =~ "^/radicale/" {
  proxy.server = ( "" => (( "host" => "127.0.0.1", "port" => "5232" )) )
  proxy.header = ( "map-urlpath" => ( "/radicale/" => "/" ))
  setenv.add-request-header = (
    "X-Script-Name" => "/radicale",
  )
  url.rewrite-once = ( "^/radicale/radicale/(.*)" => "/radicale/$1" )
}

rkoe avatar Sep 16 '23 16:09 rkoe

Thanks @rkoe - I've updated the PR

bobrippling avatar Sep 18 '23 17:09 bobrippling