6. nginx 配置 tomcat集群

nginx 负载均衡配置

1.在nginx.conf中的server{}节点上面添加

#和 sever节点同级   
include ttt/*.conf;

2.在nginx.conf 同级创建ttt目录,里面添加aslan.conf配置文件

upstream www.aslan.com{
    server 127.0.0.1:18080 weight=1;
    server 127.0.0.1:28080 weight=1;
 }
server {
    listen 80;
    server_name wwww.aslan.com;
    location / {
        proxy_pass http://www.aslan.com;
    }
}

3.检查nginx配置文件是否有问题

root@ubuntuserver:/usr/local/nginx/sbin# ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

4.重启nginx

root@ubuntuserver:/usr/local/nginx/sbin# ./nginx -s reload
root@ubuntuserver:/usr/local/nginx/sbin# 

5.访问nginx

负载均衡没问题
posted @ 2018-02-06 14:15  snakejia  阅读(137)  评论(0编辑  收藏  举报