您好,登錄后才能下訂單哦!
本文小編為大家詳細(xì)介紹“Apache服務(wù)的反向代理及負(fù)載均衡怎么配置”,內(nèi)容詳細(xì),步驟清晰,細(xì)節(jié)處理妥當(dāng),希望這篇“Apache服務(wù)的反向代理及負(fù)載均衡怎么配置”文章能幫助大家解決疑惑,下面跟著小編的思路慢慢深入,一起來(lái)學(xué)習(xí)新知識(shí)吧。
安裝apache
后端主機(jī)直接yum安裝
yum install httpd -y
反向代理端采用源碼編譯安裝
yum install apr-devel pcre-devel apr-util-devel openssl-devel -y
編譯安裝apache服務(wù)
cd /usr/local/src/
wget http://mirrors.hust.edu.cn/apache/httpd/httpd-2.2.34.tar.gz
tar zxf httpd-2.2.34.tar.gz
cd httpd-2.2.34
./configure --prefix=/usr/local/http --enable-so --enable-modules="all"
make && make install
修改后端主機(jī)的端口為8080
sed -i "s#Listen 80#Listen 8080#g" /etc/httpd/conf/httpd.conf
/etc/init.d/httpd start
配置反向代理服務(wù)器
首先開(kāi)啟相關(guān)模塊
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
修改配置文件
cat >>/usr/local/http/conf/httd.conf << EOF
ProxyPass /mgg balancer://mingongge
ProxyPassReverse /mgg balancer://mingongge
<Proxy balancer://mingongge>
BalancerMember http://10.0.0.10:8080
BalancerMember http://10.0.0.100:8080
</Proxy>
啟動(dòng)服務(wù)
/usr/local/http/bin/apachectl -k start
測(cè)試反向代理與負(fù)載均衡
[root@centos6-001 ~]# curl http://10.0.0.100:8080
welcome to mingongge.com
[root@centos6-001 ~]# curl http://10.0.0.10:8080
welcont to 10.0.0.10
測(cè)試負(fù)載均衡
[root@centos6-001 ~]# curl http://10.0.0.100/mgg
welcont to 10.0.0.10
[root@centos6-001 ~]# curl http://10.0.0.100/mgg
welcome to mingongge.com
[root@centos6-001 ~]# curl http://10.0.0.100/mgg
welcont to 10.0.0.10
[root@centos6-001 ~]# curl http://10.0.0.100/mgg
welcome to mingongge.com
讀到這里,這篇“Apache服務(wù)的反向代理及負(fù)載均衡怎么配置”文章已經(jīng)介紹完畢,想要掌握這篇文章的知識(shí)點(diǎn)還需要大家自己動(dòng)手實(shí)踐使用過(guò)才能領(lǐng)會(huì),如果想了解更多相關(guān)內(nèi)容的文章,歡迎關(guān)注億速云行業(yè)資訊頻道。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。