nginx负载均衡集群
網絡7層
nginx的負載均衡和lvs相比,nginx屬于更高級的應用層,不牽扯到IP和內核的改動,它只是單純地把用戶的請求轉發到后面的機器上。這就意味著,后端的RS不需要配置公網IP。
nginx分發器(一個公網ip192.168.31.166 和一個內網ip192.168.21.166)。?
RS1只有內網ip(192.168.21.100)?
RS2只有內網ip(192.168.21.101)
在nginx分發器上編輯配置文件?
# vim /usr/local/nginx/conf/vhosts/lb.conf?
加入如下內容
upstream test {
??
? ip_hash;
? ? server 192.168.1.122; weight=2
? ? ?server 192.168.1.124; weight=1
?
?}
? ? ?server {
? ? ? ? ? ? listen 80;
? ? ? ? ? ? server_name bbs.aaa.cn;
? ? ? ? ? ? location / {
?
? ? ? ? ? ? ? ?proxy_pass ? ? ?http://test/;
? ? ? ? ? ? ? ? proxy_set_header Host ? $host;
? ? ? ? ? ? ? ? proxy_set_header X-Real-IP ? ? ?$remote_addr;
? ? ? ? ? ? ? ? proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
? ? ? ? ? ? }
? ? ? ? }
轉載于:https://blog.51cto.com/10907714/1733141
總結
以上是生活随笔為你收集整理的nginx负载均衡集群的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JMS笔记(一)
- 下一篇: 不要使用字符串常量作为对象锁去同步代码