Lighty RoR: lighttpd mod_proxy_core Mongrel...

来源:百度文库 编辑:神马文学网 时间:2024/07/07 02:05:37
經過上一篇的Mongrel Cluster ,我們可以發現到我們已經可以配置 Mongrel Cluster,再來的問題就是如何使用他?有鑑於之前寫過的Lighttpd mod_proxy_core 的歷史,我們使用 Lighttpd mod_proxy_core 來使用 Mongrel Cluster。
首先,先配置 Mongrel Cluster 在本機端
mongrel_rails cluster::configure \
-e production \
-p 8000 \
-N 3 \
-c /var/www/servers/ \
-a 127.0.0.1 \
--user mongrel \
--group mongrel -e :代表啟動那個環境,這裡是 production 環境 -p :代表開始從那個 port 開始 listen,這裡是 8000 -N :代表一次 cluster 啟動幾個 Mongrel,這裡是三個 -c :代表 Mongrel 啟動那個目錄 -a :代表 listen 在那個 ip --user :代表以那個 user 啟動 Mongrel --group :代表以那個 group 開始啟動
我們啟動了三個 Mongrel Cluster,並且 Listen 8000 , 8001 , 8002 port。然後下載這份 Lighttpd trunk (預計會在 1.5 放入 Lighttpd )
./configure && make && make install
再來,將 lighttpd.conf 加入
server.modules = ( ..... , "mod_proxy_core" , ....)並將在 lightppd.conf 寫入下列的設定
$HTTP["host"] == "domain.example.com" {
proxy-core.balancer = "round-robin"
proxy-core.protocol = "http"
proxy-core.backends = ( "127.0.0.1:8000", "127.0.0.1:8001" , "127.0.0.1:8002")
}
proxy-core.balancer 代表的意思是如何去分配的 ,一共有 hash, fair, rr 三個 balancer。剩下的都很好看懂吧。
最後重起 lighttpd 即可,這裡的 mod_proxy_core 主要是作 reverse_proxy 的工作
參考連結
Rails, Mongrel, Lighty and MintPRE-RELEASE: lighttpd-1.5.0-r1454.tar.gzmod-proxy-core and SQFLighttpd 1.5 + Linux Async IO