Lighttpd configuration for proxy / rewrite from one domain to another

I need to configure proxies / rewrite to lighttpd!

I have server1, which serves through http 2 different web application paths:

* http://server1/path1
* http://server1/path2

Also, I have a lighttpd server in front of server1

I want to configure rewriting and / or proxying on lighttpd so that each of the two paths serves as the root path in different domains:

* requests to http://server2.com/* are proxied/rewrited to http://server1/path1/*
* requests to http://server3.com/* are proxied/rewrited to http://server1/path2/*

important:

  • server2.com and server3.com can access server1 only through http
  • redirects are not an option, server2.com and server3.com users should not know that the actual web applications are served from different server1 paths.

Is it possible?

+5
source share
1 answer

lighttpd .

.

Lighttpd 1.4

bugtracker: # 164

$HTTP["url"] =~ "(^/path1/)" {   
  proxy.server  = ( "" => ("" => ( "host" => "127.0.0.1", "port" => 81 ))) 
}

$SERVER["socket"] == ":81" {   
  url.rewrite-once = ( "^/path1/(.*)$" => "/$1" )   
  proxy.server  = ( "" => ( "" => ( "host" => "server2.com", "port" => 80 ))) 
}

Lighttpd 1.5

( ):

proxy-core.rewrite-request: uri.

$HTTP["url"] =~ "^/path1" {
  proxy-co...

  proxy-core.rewrite-request = (
    "_uri" => ( "^/path1/?(.*)" => "/$1" ),
    "Host" => ( ".*" => "server2.com" ),
  )
}
+3

All Articles