# 软件版本
ngix-1.12.0 win版本
# 配置一个应用集群(也就是一个代理服务器),服务在80端口,代理2个应用,
分别为 127.0.0.1:8080和127.0.0.2:8001,
连接代理服务器的超时时间为3秒,也就是超过3秒后会连接另外一个代理服务器。
conf/ngix.conf里这样写:
...
# 连接代理服务器的超时时间为3秒,也就是超过3秒后会连接另外一个代理服务器
proxy_connect_timeout 3;
upstream myproject {
# 代理2个应用
server 127.0.0.1:8080 ;
server 127.0.0.2:8001;
hash $cookie_jsessionid;
# 根据sessionid 决定 使用哪个节点。 原文请看 http://nginx.org/en/docs/http/ngx_http_upstream_module.html#upstream
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://myproject;
}
...