Skip to content

Instantly share code, notes, and snippets.

@joseb0rges
Last active May 25, 2018 03:07
Show Gist options
  • Save joseb0rges/428b5107ca36cce983fc1ac1d592243b to your computer and use it in GitHub Desktop.
Save joseb0rges/428b5107ca36cce983fc1ac1d592243b to your computer and use it in GitHub Desktop.
vhost_traffic_status - NGINX.md

Module installation procedure - vhost_traffic_status - NGINX

# - Dependencies

yum -y install gcc gcc-c++ make zlib-devel pcre-devel openssl-devel geoip-devel

# - Download Packages

# - nginx-module-vts

 git clone git://github.com/vozlt/nginx-module-vts.git

# - nginx-module-sts

 git clone git://github.com/vozlt/nginx-module-sts.git

# - nginx-module-stream-sts

 git clone git://github.com/vozlt/nginx-module-stream-sts.git

# - nginx - install

Version used: nginx-1.14.0

# - Compilation

./configure --prefix=/etc/nginx \
            --sbin-path=/usr/sbin/nginx \
            --modules-path=/usr/lib64/nginx/modules \
            --conf-path=/etc/nginx/nginx.conf \
            --error-log-path=/var/log/nginx/error.log \
            --pid-path=/var/run/nginx.pid \
            --lock-path=/var/run/nginx.lock \
            --user=nginx \
            --group=nginx \
            --build=CentOS \
            --with-select_module \
            --with-poll_module \
            --with-threads \
            --with-file-aio \
            --with-http_ssl_module \
            --with-http_v2_module \
            --with-http_realip_module \
            --with-http_addition_module \
            --with-http_geoip_module=dynamic \
            --with-http_sub_module \
            --with-http_dav_module \
            --with-http_gunzip_module \
            --with-http_gzip_static_module \
            --with-http_auth_request_module \
            --with-http_random_index_module \
            --with-http_secure_link_module \
            --with-http_degradation_module \
            --with-http_slice_module \
            --with-http_stub_status_module \
            --http-log-path=/var/log/nginx/access.log \
            --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 \
            --with-mail=dynamic \
            --with-mail_ssl_module \
            --with-stream \
            --with-stream_ssl_module \
            --with-stream_realip_module \
            --with-stream_geoip_module=dynamic \
            --with-stream_ssl_preread_module \
            --with-compat \
            --with-pcre \
            --add-dynamic-module=/opt/nginx-module-vts \
            --add-dynamic-module=/opt/nginx-module-sts \
            --add-module=/opt/nginx-module-stream-sts \
            --with-debug

make
make-install

# - Create the NGINX system user and group:

useradd --system --home /var/cache/nginx --shell /sbin/nologin --comment "nginx user" --user-group nginx

mkdir -p /var/cache/nginx && nginx -t

# - Create a systemd unit file for nginx:

vim /usr/lib/systemd/system/nginx.service

[Unit]
Description=nginx - high performance web server
Documentation=https://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID

[Install]
WantedBy=multi-user.target

# - Start and enable the NGINX service:

systemctl start nginx.service && sudo systemctl enable nginx.service

# - Load_module directive:

sed -i '1s;^;load_module "/usr/lib64/nginx/modules/ngx_http_vhost_traffic_status_module.so"\;\n;' /etc/nginx/nginx.conf

OBS -> Configure /nginx-status use references

# - References

# - Conclusion

selecao_001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment