使用proxy可以使lighttpd成為一個代理服務器。例如將java的請求全都轉向給jboss來處理
mod_proxy有三個標簽:
proxy.debug,0或者1. 表示是否啟動調試模式。 1表示啟動
proxy.balance,使用負載均衡的模式。可以使“hash”,“round-robin”,”fair”三種模式之一。
’round-robin’ 交替輪訓, ‘hash’ 根據請求的url產生一個 hash值,來確保同樣的請求的url都訪問同樣的主機
‘fair’ is the normal load-based, passive balancing.
語法結構
( <extension> =>
( [ <name> => ]
( "host" => <string> ,
"port" => <integer> ),
( "host" => <string> ,
"port" => <integer> )
),
<extension> => …
)
* : 表示請求url的文件擴展名或者文件前綴 (如果以”/”開始); 可以是空 (“”) 表示所有的請求
* : 可選名稱
* “host”: 被代理的服務器的ip
* “port”: 被代理服務器的端口,默認是80
如:
proxy.server = ( ".jsp" =>
( (
"host" => "10.0.0.242",
"port" => 8080
) )
)
再如:
$HTTP["host"] == "www.domain.me" {
proxy.server = ( "" =>
( (
"host" => "127.0.0.1",
"port"=>"8080"
) )
)
}
負載均衡的例子,例如有8個squid緩存,需要用lighttpd做負載均衡
$HTTP["host"] == "www.example.org" {
proxy.balance = "hash"
proxy.server = ( "" => ( ( "host" => "10.0.0.10" ),
( "host" => "10.0.0.11" ),
( "host" => "10.0.0.12" ),
( "host" => "10.0.0.13" ),
( "host" => "10.0.0.14" ),
( "host" => "10.0.0.15" ),
( "host" => "10.0.0.16" ),
( "host" => "10.0.0.17" ) ) )
}
當一個服務器宕機后,它上面的請求將被轉移給其他設備server
posted on 2011-06-22 23:20
Alpha 閱讀(2325)
評論(0) 編輯 收藏 所屬分類:
Java J2EE JSP 、
Linux Nginx