1,架構思想


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的節點
}
}

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
- - - - - -
- 01【熟悉】服務器概述
- 02【熟悉】Nginx概述
- 1、前言
- 2、為什么使用Nginx?
- 3、什么是Nginx?
- 3.1 Nginx的應用場景
- 4、小結
- 03【掌握】在Cento7系統下安裝Nginx
- 1、下載Nginx
- 2、安裝
- 2.1 環境要求
- 2.2 先安裝nginx依賴的包
- 2.3 把nginx的源碼上傳到linux系統,并解壓
- 2.4 安裝
- 2.5 Nginx的目錄說明
- 2.6 Nginx的?啟動、停止
- 04【掌握】Nginx基礎配置詳解
- 1、Nginx的配置
- 1.1 端口和目錄的配置
- 1.2 通過域名虛擬機
- 05【掌握】反向代理+負載均衡
- 1.1.正向代理
- 1.2.反向代理
- 2,負載均衡
- 3,反向代理+負載均衡的配置
- 4,其它配置
- 5, 登陸session的配置問題
- 06【掌握】動靜分離
- 1,概述
- 2,動靜分離的配置
- 3,動靜分離的配置正則說明