Nginx 添加sticky模块

1)下载nginx-sticky安装包nginx-goodies-nginx-sticky-module-ng-08a395c66e42
2)解压
./configure –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module –with-http_realip_module –add-module=/tmp/soft/nginx-sticky-module-1.1
make
错误信息:(再执行make && make install时报如下错误)
/tmp/soft/nginx-sticky-module-1.1/ngx_http_sticky_misc.c:281: error: too few arg
uments to function ‘ngx_sock_ntop’
make[1]: *** [objs/addon/nginx-sticky-module-1.1/ngx_http_sticky_misc.o] Error 1
make[1]: Leaving directory `/tmp/soft/nginx-1.6.2′
make: *** [build] Error 2
3)更改ngx_http_sticky_misc.c
ngx_http_sticky_misc
把ngx_http_sticky_misc.c 的281行修改如下即可解决问题
原digest->len = ngx_sock_ntop(in,digest
->data, len, 1);
改后digest->len = ngx_sock_ntop(in,sizeof(struct sockaddr_in),digest
->data, len, 1);
4)更改ngx_http_sticky_module.c
ngx_http_sticky_module
在#include 上一行增加
#include

在iphp->rrp.current = iphp->selected_peer; 上一行增加
#if defined(nginx_version) && nginx_version >= 1009000
iphp->rrp.current = peer;
#else
在iphp->rrp.current = iphp->selected_peer; 下一行增加
#endif

5)配置nginx
cd /usr/local/nginx/conf
vi nginx.conf
upstream webmerserServer{
sticky;
server 10.10.38.196:8018;
server 10.10.38.196:8028;
}

如果下载nginx-sticky包是nginx-sticky-module-1.1.tar.gz,不需要修改配置文件
1)./configure –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module –with-http_realip_module –add-module=/tmp/soft/nginx-sticky-module-1.1
2)make
3)make install
4) 查看nginx
cd /usr/local/nginx/sbin
./nginx -V
[root@slave01 sbin]# ./nginx -V
nginx version: nginx/1.10.2
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-52)
built with OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
TLS SNI support disabled
configure arguments: –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module –with-pcre=/root/local/pcre-8.35 –add-module=/root/local/nginx-sticky

发表评论

电子邮件地址不会被公开。 必填项已用*标注