0

I've a Lighttpd server running on HTTPS, and I want to have one subdirectory on the server act as a reverse proxy for a separate server that runs on HTTP. I've tried following guides on doing both proxy and url rewrite, but something to do with how the SSL is set up is interfering.

$SERVER["socket"] == ":81" {
    url.rewrite-once = ( "^/directory/(.*)$" => "/index.html" )
    proxy.server  = ( "" => ( "" => ( "host" => "192.0.0.1", "port" => 123 )))
}

$HTTP["scheme"] == "http" {
     $HTTP["host"] =~ ".*" {
        url.redirect = (".*" => "https://%0$0")
     }
}

$SERVER["socket"] == ":443" {
        ssl.engine = "enable"
        ssl.ca-file = "/etc/lighttpd/fullchain.pem"
        ssl.pemfile = "/etc/lighttpd/server.pem"
        $HTTP["url"] =~ "^/directory/" {
               proxy.server = ( "" => ( "" => ( "host" => "127.0.0.1", "port" => 81)))
        }
}

My intention was that going to /directory/ would redirect you to the 192.0.0.1:123/index.html. I followed this guide which mentioned doing the first redirect to port 81, then redirecting port 81 to the second server.

This doesn't seem to work and just gets stuck in a redirection loop, and always returns a 301 to the https site.

If I don't do the :81 redirect, I can get the bottom proxy.server to redirect to the right place, but it keeps the /directory/ ending which doesn't get to where I need it.

Thanks.

0

lighttpd 1.4.46 and later have a feature in mod_proxy which allows remapping url-path prefixes. See the 'proxy.header' directive and "map-urlpath" sub-option.

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

This feature avoids the double-proxy config you are trying to use.

lighttpd 1.4.46 was released just over a year ago and the latest lighttpd release is lighttpd 1.4.51.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.