4

I'm really just starting out with lighttpd and I'm not sure how to configure this exactly.

I'm wanting to take traffic and redirect to another server say "http://localhost/url_a/" and redirect the request and responses from that to "http://other_server:8080/"

Another example would be "http://localhost/url_b/" going to "http://other_server:8081/url_b/"

What exactly should I look into for accomplishing this?

Thanks.

  • 3
    Do you want a redirect (i.e. send the client to the other location), or do you want to proxy (Lighttpd connects to the other location and sends the response to the client)? – mgorven Oct 23 '12 at 17:56
  • I'd like more of a proxy. – daelious Oct 23 '12 at 18:16
3

In Lighttpd 1.4 you need to use mod_proxy to forward the request to another server.

proxy.server = ("/url_a" => ((
    "host" => "1.2.3.4",
    "port" => 8080,
)))

Changing the URL path or virtual hostname is a bit tricky in 1.4. If you're using 1.5 you can use mod_proxy_core instead, which is more configurable:

$HTTP["url"] =~ "^/url_a" {
    proxy-core.protocol = "http"
    proxy-core.backends = ("other_server:8080")
    proxy-core.rewrite-request = (
        "_uri" => ( "^/url_a/?(.*)" => "/$1" ),
        "Host" => ( ".*" => "other_server" ),
    )
}
  • 1
    I'm currently limited to using only 1.4. Since 1.5 isn't compiling very well. – daelious Oct 24 '12 at 16:56

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.