使用Nginx作为代理服务器,apache作为代码服务器,实现负载均衡。
一、nginx的安装参考:http://blog.sina.com.cn/s/blog_13d75827d0102ylho.html
二、反向代理的配置:
详解:
1、代码服务器的IP weight——权重,当使用轮询的方式时,权重可以决定请求到每台服务器的频率。
各种内置策略详解:https://www.cnblogs.com/wpjamer/articles/6443332.html
2、同上
3、监听的端口
4、域名(IP)代理服务器的ip或者域名
5、6、多项目的转发
配置如下:
upstream lamp {
#ip_hash;
server 192.168.2.4 weight=1;
server 192.168.2.5 weight=1;
#fair;
}
server {
listen 80;
server_name 192.168.2.6;
location / {
proxy_pass http://lamp/;
}
location /gaowang/ {
proxy_pass http://lamp/gaowang/;
}
location /tp/ {
proxy_pass http://lamp/tp5.0/public/index.php/;
}