nginx负载均衡tomcat

1.三台服务器:
oldboy1 10.160.1.15
oldboy2: 10.160.1.236
oldboy3: 10.160.1.39
2.oldboy1安装nginx
yum install nginx -y
3.oldboy2和oldboy3安装tomcat
cd /usr/local/
tar xf apache-tomcat-10.0.10.tar.gz
mv apache-tomcat-10.0.10 tomcat10
启动tomcat
/usr/local/tomcat/bin/startup.sh
3.配置oldboy1nginx文件
[root@oldboy1 ~]# cat /etc/nginx/nginx.conf
worker_processes 6;
events {
worker_connections 2048;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream backend {
server 10.160.1.236:8080 weight=3;
server 10.160.1.39:8080 weight=1;
}

server {
    listen       80;
    server_name  127.0.0.1;
    location / {
        proxy_pass http://backend;
        proxy_set_header Host  $host;
    }

}
}
4.启动nginx
systemctl start nginx
5.访问oldboy1nginx


image.png

你可能感兴趣的:(nginx负载均衡tomcat)