使用proxy可以使lighttpd成為一個(gè)代理服務(wù)器。例如將java的請求全都轉(zhuǎn)向給jboss來處理
mod_proxy有三個(gè)標(biāo)簽:
proxy.debug,0或者1. 表示是否啟動調(diào)試模式。 1表示啟動
proxy.balance,使用負(fù)載均衡的模式。可以使“hash”,“round-robin”,”fair”三種模式之一。
’round-robin’ 交替輪訓(xùn), ‘hash’ 根據(jù)請求的url產(chǎn)生一個(gè) hash值,來確保同樣的請求的url都訪問同樣的主機(jī)
‘fair’ is the normal load-based, passive balancing.
語法結(jié)構(gòu)
( <extension> =>
( [ <name> => ]
( "host" => <string> ,
"port" => <integer> ),
( "host" => <string> ,
"port" => <integer> )
),
<extension> => …
)
* : 表示請求url的文件擴(kuò)展名或者文件前綴 (如果以”/”開始); 可以是空 (“”) 表示所有的請求
* : 可選名稱
* “host”: 被代理的服務(wù)器的ip
* “port”: 被代理服務(wù)器的端口,默認(rèn)是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"
) )
)
}
負(fù)載均衡的例子,例如有8個(gè)squid緩存,需要用lighttpd做負(fù)載均衡
$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" ) ) )
}
當(dāng)一個(gè)服務(wù)器宕機(jī)后,它上面的請求將被轉(zhuǎn)移給其他設(shè)備server
posted on 2011-06-22 23:20
Alpha 閱讀(2325)
評論(0) 編輯 收藏 所屬分類:
Java J2EE JSP 、
Linux Nginx