nginx 1.3.11 + sticky-1.1 负载均衡配置
一、下载nginx 1.3.11 和sticky 1.1会话保持组件
下载地址分别是
http://nginx.org/download/nginx-1.3.11.tar.gz
https://nginx-sticky-module.googlecode.com/files/nginx-sticky-module-1.1.tar.gz
解压nginx 得到?nginx-1.3.11文件夹
解压sticky得到nginx-sticky-module-1.1文件夹
将nginx-sticky-module-1.1 移动到?nginx-1.3.11文件夹下
应该是这样的?nginx-1.3.11/nginx-sticky-module-1.1
二、开始安装...首先在nginx-1.3.11目录下执行
./configure ?--add-module=nginx-sticky-module-1.1
然后再执行
make && make install
三、配置注意upstream?后面的地址不能带端口,否则会死循环
?
upstream 192.168.56.37{
? ? ?sticky;#会话保持
? ? ?server 192.168.56.34:9080;#负载地址
? ? ?server 192.168.56.43:9080;#负载地址
? ? }
server {
? ? ? ? listen ? ? ? 9080;
? ? ? ? server_name ?localhost;
?
? ? ? ? #charset koi8-r;
?
? ? ? ? #access_log ?logs/host.access.log ?main;
?
? ? ? ? location / {
? ? ? ? ? ? root ? html;
? ? ? ? ? ? index ?index.html index.htm;
? ? ? ? ? ? proxy_pass http://192.168.56.37;
? ? ? ? }
...
}