1.准备
1.nginx 下载地址 2.tomcat 下载地址
2.启动
1.tomcat安装配置这里不再赘述
2.nginx启动后访问浏览器 默认端口80这里我改了10010
start nginx
访问浏览器若不成功可能端口冲突,在nginx的conf.xml 修改一下listen 值
3.启动俩个tomcat服务
4.nginx 中的conf.xml进行配置,达到对着俩个tomcat的负载均衡 conf.xml文件的配置
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
upstream fx.com {
server localhost:8080 weight=1;
server localhost:8081 weight=2;
}
server {
listen 10010;
server_name localhost;
charset utf-8;
location / {
root html;
index index.html index.htm;
proxy_pass http://fx.com;
proxy_set_header X-Real-IP $remote_addr;
client_max_body_size 100m;
}
}
}
5.重启nginx
nginx -s reload
6.访问nginx地址可以看到已对这俩tomcat实现负载均衡
|