201*_*450 6 mod-rewrite lighttpd mod-proxy
我需要在lighttpd上设置代理/重写!
我有server1,它通过http 2不同的web应用程序路径提供服务:
* http://server1/path1
* http://server1/path2
Run Code Online (Sandbox Code Playgroud)
另外,我在server1前面有lighttpd服务器
我想在lighttpd上设置重写和/或代理,以便2条路径中的每条路径都可以作为不同域上的根路径:
* requests to http://server2.com/* are proxied/rewrited to http://server1/path1/*
* requests to http://server3.com/* are proxied/rewrited to http://server1/path2/*
Run Code Online (Sandbox Code Playgroud)
重要:
可能吗?
几年来,lighttpd开发人员已知道您的需求。
可以通过解决方法或新功能(取决于版本)来解决。
Lighttpd 1.4
在bugtracker中解释了一种解决方法:bug#164
Run Code Online (Sandbox Code Playgroud)$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。
Run Code Online (Sandbox Code Playgroud)$HTTP["url"] =~ "^/path1" { proxy-co... proxy-core.rewrite-request = ( "_uri" => ( "^/path1/?(.*)" => "/$1" ), "Host" => ( ".*" => "server2.com" ), ) }
归档时间: |
|
查看次数: |
5722 次 |
最近记录: |