Project

General

Profile

reverse proxy redirect failure

Added by dg100101 over 10 years ago

Hi guys,

my name is Denny and i've got a problem with lighttpd and reverse proxy.

I would like to to redirect only the location /test on domain www.example.org which is a vhost (evhost.conf) to localhost port 8080 via reverse proxy.
My problem is that, if i type in the url www.example.org/test I get the error message not found.
If I look in the log file of the application listen on localhost port 8080 I can see that lighttpd want to try to revers proxy www.example.org/test to 127.0.0.1:8080/test
but I want to reverse proxy www.example.org/test to 127.0.0.1:8080.

Here is a part of my evhost.conf:

$HTTP["url"] =~ "/test" {
$HTTP["host"] =~ "^www\.example\.org" {
proxy.server = ( "" =>
(( "host" => "127.0.0.1", "port" => 8080 ))
)
}
}

Here additional info:

OS: Centos 6.3
Lighttpd: lighttpd/1.4.32 (ssl) (Aug 26 2013 13:27:59)

I also tried the following configurtion with the same error:

$HTTP["host"] =~ "^www\.example\.org" {
proxy.server = ( "/test" =>
(( "host" => "127.0.0.1", "port" => 8080 ))
)
}
}

Thanks

Best Regards
Denny


Replies (4)

RE: reverse proxy redirect failure - Added by stbuehler over 10 years ago

The easiest and correct solution is to make your backend handle the request at /test - i.e. the backend should be able to handle exactly the request the frontend gets. This makes sure that redirects and links from your backend are working correctly.

rewriting the url in the frontend (lighttpd) will fail; rewrite restarts the request, and then your $HTTP["url"] =~ "/test" conditional won't match anymore.

RE: reverse proxy redirect failure - Added by dg100101 over 10 years ago

Hi stbuehler,

Thanks for your quick reply. Is it possible to type in www.example.org/test and reverse proxy to 127.0.0.1:8080/web ?
This could be a solution for me and i would be very happy if you could post a example. But it should just work for
virtual host www.example.org other virtual hosts should not be affected.

Thanks

Denny

RE: reverse proxy redirect failure - Added by stbuehler over 10 years ago

You could proxy /web, and rewrite /test to /web, so /test too gets proxied as /web - this probably wouldn't break links, but you can't use /web for something else.

Don't think of proxying to 127.0.0.1:8080/web - you forward the request for www.example.org/test to another socket, the request doesn't change much.

RE: reverse proxy redirect failure - Added by dg100101 over 10 years ago

Thanks very much,

Do have some example config lines for me ?

    (1-4/4)