Home > OS >  Redirecting page to specific IP and port in lighttpd
Redirecting page to specific IP and port in lighttpd

Time:09-22

I got 2 server under same network and I hope to redirect domain.com/page to 192.168.2.16:22348 so i got this in lighttpd.conf according to this: lighttpd as reverse-proxy

$HTTP["url"] =~ "^/page" {
  proxy.server = ( "" => ( ( "host" =>  "192.168.2.16", "port" => 22348 ) ) )
}

but I ended up getting redirected to 192.168.2.16/maps which doesn't exist (I only got index.html but I can't change it) and returned 404. Is there any way to only pass IP and port but not /page?

(I also tried domain.com/google to google.com by the same way but ended up to google.com/google)

Others I also tried: https://redmine.lighttpd.net/projects/1/wiki/Docs_ModProxy

CodePudding user response:

Others I also tried: https://redmine.lighttpd.net/projects/1/wiki/Docs_ModProxy

I think you should look at proxy.header "map-urlpath" on the same page.

CodePudding user response:

So instead of using www.domain.com/page, i decided to use subdomain.domain.com. Here's what I got.

$HTTP["host"] =~ "subdomain.domain.com" {
  proxy.server = ( "" =>  ( ( "host" => "192.168.2.16", "port" => "22348" ) ) )
}

Since there is nothing after subdomain.domain.com/, it won't pass anything but only ip and port (192.168.2.16:22348) so I don't need to modify anything from the second machine. I think this is easier to configure instead of using /page.

  • Related