http{ 下增加
upstream tomcat_server {
server 1.1.7.75:8087 weight=10;#第一台机器
server 1.1.7.75:8088 weight=10;#第二台机器
}
server
location / {
下面增加
#下面3行设置反向代理 可以增加其他的参数
proxy_set_header Host $host;
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 已经处理完正在等候下一次请求指令的驻留连接。