tengine安装,haproxy访问不同路径对接不同集群
tengine安装
下载包:在官网 http://tengine.taobao.org/download_cn.html下载各种版本的tengine包
./configure make make install
将tengine设置为service服务
cd /usr/lib/systemd/system vi nginx.service
[Unit] Description=nginx performance web server Documentation=http://tengine.taobao.org/documentation_cn.html After=syslog.target network.target remote-fs.target nss-lookup.target [Service] Type=forking PIDFile=/var/run/nginx.pid ExecStartPre=/usr/local/nginx/sbin/nginx -t ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target
修改/usr/local/nginx/conf/nginx.conf文件
添加:
pid /var/run/nginx.pid;
systemctl enable nginx
systemctl start nginx
systemctl status nginx
实现api.x.com代理9001端口
192.168.115.128机器修改nginx.conf
server { listen 80; server_name api.x.com; location / { root html; proxy_pass http://192.168.115.129:9001; #另外一台的nginx监听9001端口 index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }
haproxy实现7层代理,访问不同路径对应不同集群
haproxy.conf配置文件修改
frontend main *:5000 acl url_static1 path_beg -i /static /images /javascript /stylesheets /a #不同的访问路径 acl url_static path_end -i .jpg .gif .png .css .js use_backend static1 if url_static1 #a集群 acl url_static2 path_beg -i /static /images /javascript /stylesheets /b #不同的访问路径 use_backend static2 if url_static2 #b集群 default_backend app #--------------------------------------------------------------------- # static backend for serving up images, stylesheets and such #--------------------------------------------------------------------- backend static balance roundrobin server static 127.0.0.1:4331 check #--------------------------------------------------------------------- # round robin balancing between the various backends #--------------------------------------------------------------------- backend app balance roundrobin server app1 192.168.115.128:80 check server app2 192.168.115.129:80 check backend static1 #a集群 balance roundrobin server static1 192.168.115.128:80 check backend static2 #b集群 balance roundrobin server static2 192.168.115.129:80 check
访问a集群:
访问b集群:
相关推荐
Neptune 2019-12-20
泥淖 2019-12-05
dongliwei 2016-12-02
sichenglain 2020-05-19
BigDataMining 2020-03-25
老甘的可读区 2020-03-08
yungame 2020-03-01
畅聊架构 2020-02-26
mycosmos 2020-02-19
秋风瑟瑟 2020-01-18
zllbirdonland 2020-01-11
dbhllnr 2020-01-09
畅聊架构 2020-01-03
zllbirdonland 2019-12-28
GeorgeTH 2019-12-28
xiaoyatouvsanan 2014-05-14
YzhilongY 2014-05-13
liym 2019-12-22
OwenJi 2019-12-13