5

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.

daelious
  • 53
  • 1
  • 1
  • 4
  • 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

1 Answers1

4

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" ),
    )
}
mgorven
  • 30,036
  • 7
  • 76
  • 121