运维小知识之nginx---..nginx-sticky-module-1.1ngx_http_sticky_misc.cIn function ‘ngx_http_sticky_misc_text_raw
背景
今天笔者在使用nginx做负载均衡的过程中遇到了一个问题,如何解决session共享的问题,稍一查找发现解决办法不少,笔者使用的是nginx的一直扩展模块(安装和配置已经在前两篇博客有简单的介绍)在安装的过程中居然出现了问题,咱也不是逃避的人,解决吧,见下文。
问题描述
make[1]: Entering directory`/usr/local/nginx-1.7.4'
cc -c -pipe -O -W -Wall -Wpointer-arith-Wno-unused-parameter -Werror -g -I src/core-I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -Isrc/http/modules -I src/mail \-oobjs/addon/nginx-sticky-module-1.1/ngx_http_sticky_misc.o \../nginx-sticky-module-1.1/ngx_http_sticky_misc.c
cc1: warnings being treated as errors
../nginx-sticky-module-1.1/ngx_http_sticky_misc.c:In function ‘ngx_http_sticky_misc_text_raw’:
../nginx-sticky-module-1.1/ngx_http_sticky_misc.c:281:error: passing argument 2 of ‘ngx_sock_ntop’makes integer from pointer without a cast
src/core/ngx_inet.h:110: note: expected ‘socklen_t’ but argument is of type ‘u_char *’
../nginx-sticky-module-1.1/ngx_http_sticky_misc.c:281:error: passing argument 3 of ‘ngx_sock_ntop’makes pointer from integer without a cast
src/core/ngx_inet.h:110: note: expected ‘u_char*’ but argument is of type ‘size_t’
../nginx-sticky-module-1.1/ngx_http_sticky_misc.c:281:error: too few arguments 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`/usr/local/nginx-1.7.4'
make: *** [build] Error 2
解决方法
进入nginx-sticky-module-1.1解压之后的文件夹
cd /usr/local/nginx-sticky-module-1.1
编辑文件夹里面的ngx_http_sticky_module.c文件
vi ngx_http_sticky_module.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);
后记
今天状态不做,便把遇到的问题以及解决方法都稍微整理了一下,希望对读者有帮助,其实自己忘了,也能回来看看,一举两得。