🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
1,架构思想 ![](https://img.kancloud.cn/5c/8b/5c8be0f18a6ea5255186c6ab70ef6b19_792x504.png) ![](https://img.kancloud.cn/ed/60/ed60c5cccc6055919f86cc50f565a648_793x385.png) 2,准备三个tomcat \#把原来的tomcat改个名这字 mv apache-tomcat-7.0.90 tomcat1 \#复制两个 cp -r tomcat1 tomcat2/ cp -r tomcat1 tomcat3/ ​ \#修改端口号 tomcat1 8005 8080 8443 8009 8443 保持默认 tomcat2 8015 8090 8453 8019 8453 tomcat3 8025 8100 8463 8029 8463 ​ \#修改三个tomcat里面的webapps里面页面。让其有点区别【这里不做代码展示,自行去改】 ​ \#启动三个tomcat cd tomcat1/bin ./startup cd tomcat2/bin ./startup cd tomcat3/bin ./startup 3,配置nginx服务器 \#打开/usr/nginx cd /usr/nginx \#打开conf配置目录 cd conf \#备份里面的nginx.conf\[防止改错\] cp -r nginx.conf nginxbak.confbak \#编辑里面的nginx.conf vi nginx.conf ​ ​ \#在server节点上加入以下配置 upstream www.carrent.com { server 192.168.15.131:8080; server 192.168.15.131:8090; server 192.168.15.131:8100; \#ip\_hash;这是是用来解决登陆的session的问题 } \#修改location的配置 server { listen 80; server\_name www.carrent.com;#配置访问的域名 location / { \# root html; \# index index.html index.htm; proxy\_pass http://www.carrent.com; #指向上面配置的server的节点 } } ![](https://img.kancloud.cn/91/d8/91d82cee67be9f8d14e8659df56b496c_1238x618.png) 4,启动nginx和访问 \#启动 ./nginx \#访问 http://192.168.15.131/erp 5,解决请求过慢的问题 \#在nginx.conf文件的location里面加入如下配置 proxy\_redirect off ; proxy\_set\_header Host $host; proxy\_set\_header X-Real-IP $remote\_addr; proxy\_set\_header REMOTE-HOST $remote\_addr; proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for; client\_max\_body\_size 50m; #允许客户端请求的最大单文件字节数 client\_body\_buffer\_size 256k;#缓冲区代理缓冲用户端请求的最大字节数, proxy\_connect\_timeout 1; #nginx跟后端服务器连接超时时间(代理连接超时) proxy\_send\_timeout 30; #后端服务器数据回传时间(代理发送超时) proxy\_read\_timeout 60; #连接成功后,后端服务器响应时间(代理接收超时) proxy\_buffer\_size 256k;#设置代理服务器(nginx)保存用户头信息的缓冲区大小 proxy\_buffers 4 256k; \#proxy\_buffers缓冲区,网页平均在256k下,这样设置 proxy\_busy\_buffers\_size 256k; #高负荷下缓冲大小(proxy\_buffers\*2) proxy\_temp\_file\_write\_size 256k; \#设定缓存文件夹大小 proxy\_next\_upstream error timeout invalid\_header http\_500 http\_503 http\_404; proxy\_max\_temp\_file\_size 128m; 6,可以配置window的host去指向<http://www.erp.com> 打开C:\\Windows\\System32\\drivers\\etc\\hosts 添加如下配置 192.168.15.131 www.carrent.com 7,配置hosts不生效的解决方法 1,关闭浏览器再打开 2,刷新DNS |--打开dos窗口 |--输入ipconfig /flushdns - - - - - -