http{ 下增長html
upstream tomcat_server {nginx
server 1.1.7.75:8087 weight=10;#第一臺機器tomcat
server 1.1.7.75:8088 weight=10;#第二臺機器spa
}代理
serverorm
location / {server
下面增長htm
#下面3行設置反向代理 能夠增長其餘的參數ip
proxy_set_header Host $host;rem
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://tomcat_server;
這樣訪問http://localhost 直接到 1.1.7.75:8088 1.1.7.75:8087兩個項目了。兩個項目同樣哦。
有關nginx upstream的五種分配方式
http://tech.ddvip.com/2009-07/1246936747125436.html
#設定查看Nginx狀態的地址
location /NginxStatus {
stub_status on;
access_log on;
#auth_basic "NginxStatus"; #密碼被我取消了。
#auth_basic_user_file conf/htpasswd;
}
NginxStatus 顯示的內容意思以下:
●active connections – 當前 Nginx 正處理的活動鏈接數。
●server accepts handled requests -- 總共處理了 14553819 個鏈接 , 成功建立 14553819 次握手 ( 證實中間沒有失敗的 ), 總共處理了 19239266 個請求 ( 平均每次握手處理了 1.3 個數據請求 )。
●reading -- nginx 讀取到客戶端的 Header 信息數。
●writing -- nginx 返回給客戶端的 Header 信息數。
●waiting -- 開啓 keep-alive 的狀況下,這個值等於 active - (reading + writing),意思就是 Nginx 已經處理完正在等候下一次請求指令的駐留鏈接。