FastNetMon

Monday 7 March 2016

Установка модуля testcookie для Nginx без рекомпиляции Nginx

Мы обсуждаем, что берем Nginx и ставим его на Debian 7 или 8, на котором уже работает nginx из пакетов с сайта nginx.org.

Ставим Nginx из репозитория с офсайта.

Проверяем его версию:
nginx -V 2>&1|grep "nginx version"
nginx version: nginx/1.9.12

Потом там же берем опции компиляции:
nginx -V

Стягиваем модуль:
cd /usr/src
git clone https://github.com/kyprizel/testcookie-nginx-module.git

Ставим зависимости:
apt-get install -y libxml2-dev libxslt-dev libgd2-xpm-dev libgeoip-dev 
Собираем модуль:

cd /usr/src
wget 'http://nginx.org/download/nginx-1.9.12.tar.gz'
tar -xzvf nginx-1.9.12.tar.gz
cd nginx-1.9.12/
# configure параметры берем из выдачи nginx -V выше
./configure --add-dynamic-module=/usr/src/testcookie-nginx-module --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/etc/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-threads --with-stream --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_v2_module --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-z,relro -Wl,--as-needed' --with-ipv6
Собираем:
make

Потом берем бинарик:
mkdir /etc/nginx/modules
cp ./objs/ngx_http_testcookie_access_module.so /etc/nginx/modules

И добавляем в nginx.conf в самом верху:
load_module "modules/ngx_http_testcookie_access_module.so";

Если мы собирали не под ту версию, то в ответ получаем (и идем собирать под нужную):
[....] Restarting nginx: nginxnginx: [emerg] module "/etc/nginx/modules/ngx_http_testcookie_access_module.so" version 1009011 instead of 1009012 in /etc/nginx/nginx.conf:8

Получаем облом, если использованные параметры будут отличаться от тех, с которыми собран наш nginx:
[....] Restarting nginx: nginxnginx: [emerg] module "/etc/nginx/modules/ngx_http_testcookie_access_module.so" is not binary compatible in /etc/nginx/nginx.conf:8


Перезагружаем:
service nginx restart

Убеждаемся, что все загрузилось:
cat  /proc/5731/smaps |grep test
7f18c8441000-7f18c8448000 r-xp 00000000 09:02 6035144                    /usr/lib/nginx/modules/ngx_http_testcookie_access_module.so

4 comments :

  1. This comment has been removed by the author.

    ReplyDelete
  2. May 10 11:25:50 221 nginx[13334]: nginx: [emerg] "load_module" directive is not allowed here in /etc/nginx/nginx.conf:110

    ReplyDelete
  3. Данная директива должна находится за пределами http. Скорей всего она не в том месте

    ReplyDelete

Note: only a member of this blog may post a comment.