标签:
负载均衡配置是超大型机器需要考虑的一些问题,同时也是数据安全的一种做法,下面我来介绍在nginx中反向代理 负载均衡配置图解,大家可参考本文章来操作。
#location ~ .php$ {# proxy_pass http://127.0.0.1;#}改为 location ~ .php$ { proxy_pass http://127.0.0.1:8080;}
分别访问,出现如下图已经能够针对不同请求访问服务器了
#location ~ .php$ {# proxy_pass http://127.0.0.1;#}修改为 location ^~ /phpMyAdmin/ { proxy_pass 192.168.2.2:80 ;} location ~ .php$ { proxy_pass 192.168.2.3:8080 ;}
listen 80; server_name localhost;#charset koi8-r;#access_log logs/host.access.log main; location / { root html; index index.html index.htm;}
upstream myCluster { server 192.168.2.3:8080 ; server 192.168.2.2:80 ; server 192.168.2.8:80 ;}
location ~ .php$ { proxy_pass http://myCluster ; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}
upstream myCluster { server 192.168.2.3:8080 weight=5; server 192.168.2.2:80 ; server 192.168.2.8:80 ;}
标签:
原文地址:http://www.cnblogs.com/duanxz/p/4919132.html