NGINX编译安装sticky

提醒:目前sticky支持nginx22及以下版本,新版我试了 24 和26均会编译报错

1、下载nginx安装包

2、解压进到编译目录,有configure的目录,执行以下命令

./configure \
--prefix=/usr/local/nginx \
--with-file-aio \
--with-threads \
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_mp4_module \
--with-http_random_index_module \
--with-http_realip_module \
--with-http_secure_link_module \
--with-http_slice_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_v2_module \
--with-http_geoip_module \
--with-http_geoip_module=dynamic \
--with-mail \
--with-mail_ssl_module \
--with-stream \
--with-stream=dynamic \
--with-stream_geoip_module \
--with-stream_geoip_module=dynamic \
--with-stream_realip_module \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--add-module=sticky目录 # 比如 /home/ubuntu2/nginx22/tools/nginx-sticky-module-ng

然后没有报错就继续  make&&make install

编译成功后nginx会安装在/usr/local/nginx/ 下,编译完成。

以下是sticky的参数的意义,这些由开发提供,可以比ip_hash更有针对性的控制cookie


sticky [name=route] [domain=.foo.bar] [path=/] [expires=1h]
[hash=index|md5|sha1] [no_fallback] [secure] [httponly];
[name=route]      设置用来记录会话的cookie名称
[domain=.foo.bar]    设置cookie作用的域名
[path=/]         设置cookie作用的URL路径,默认根目录
[expires=1h]        设置cookie的生存期,默认不设置,浏览器关闭即失效,需要是大于1秒的值
[hash=index|md5|sha1] 设置cookie中服务器的标识是用明文还是使用md5值,默认使用md5
[no_fallback]       设置该项,当sticky的后端机器挂了以后,nginx返回502 (Bad Gateway or Proxy Error) ,而不转发到其他服务器,不建议设置
[secure]         设置启用安全的cookie,需要HTTPS支持
[httponly]        允许cookie不通过JS泄漏,没用过

posted @ 2024-06-14 11:10  zhg1016  阅读(16)  评论(0编辑  收藏  举报