How to enable nginx slice module?

How to enable nginx slice module?

With nginx 1.9.8 mainline, nginx introduced a new module “ngx_http_slice_module”.  Nginx slice module enables the slicing of large response like video files, and improves the “cache-ability” of these large requests.  This module is not built into nginx  by default,  so we have to enable this module while building nginx from source.

How to Enable nginx slice ( ngx_http_slice_module ) module?

We can use the “–with-http_slice_module” configuration parameter to enable slice module

1 2 3 4 5 6 7   wget http://nginx.org/download/nginx-1.11.9.tar.gz cd nginx1.11.9 ./configure withhttp_slice_module make make install  

Once installation is successful, you can verify it using

1 2 3 4 5 6 7 8   [root@test.test.com nginx1.11.9]# nginx -V nginx version: nginx/1.10.2 built by gcc 4.4.7 20120313 (Red Hat 4.4.717) (GCC) built with OpenSSL 1.0.1efips 11 Feb 2013 TLS SNI support enabled configure arguments: prefix=/usr/share/nginx sbinpath=/usr/sbin/nginx modulespath=/usr/lib64/nginx/modules confpath=/etc/nginx/nginx.conf errorlogpath=/var/log/nginx/error.log httplogpath=/var/log/nginx/access.log httpclientbodytemppath=/var/lib/nginx/tmp/client_body httpproxytemppath=/var/lib/nginx/tmp/proxy httpfastcgitemppath=/var/lib/nginx/tmp/fastcgi httpuwsgitemppath=/var/lib/nginx/tmp/uwsgi httpscgitemppath=/var/lib/nginx/tmp/scgi pidpath=/var/run/nginx.pid lockpath=/var/lock/subsys/nginx user=nginx group=nginx withfileaio withipv6 withhttp_ssl_module withhttp_v2_module withhttp_realip_module withhttp_addition_module withhttp_xslt_module=dynamic withhttp_image_filter_module=dynamic withhttp_geoip_module=dynamic withhttp_sub_module withhttp_dav_module withhttp_flv_module withhttp_mp4_module withhttp_gunzip_module withhttp_gzip_static_module withhttp_random_index_module withhttp_secure_link_module withhttp_degradation_module withhttp_slice_module withhttp_stub_status_module withhttp_perl_module=dynamic withmail=dynamic withmail_ssl_module withpcre withpcrejit withstream=dynamic withstream_ssl_module withdebug withccopt=‘-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector –param=ssp-buffer-size=4 -m64 -mtune=generic’ withldopt=‘ -Wl,-E’  

How to configure the “ngx_http_slice_module” module?

Sample configuration for using slice module is below

1 2 3 4 5 6 7 8 9 10   location / { slice 1m; proxy_cache cache; proxy_cache_key $uri$is_args$args$slice_range; proxy_set_header Range $slice_range; proxy_cache_valid 200 206 1h; proxy_pass http://localhost:8000; }  

In the above configuration, nginx acts as a reverse proxy. When a request arrives , Nginx proxies request to backend server and send back the response to the client. Also Nginx caches the responses inside its internal cache, so subsequent requests are served from cache directly.

In the case of video files, response size will be  large and client access the files using byte‑range requests ( Requests for particular byte-range of the video file intead of entire file) . With “ngx_http_slice_module” module, nginx breaks the file into smaller segments and requests each segment from backend  whenever it is required. The segments are accumulated in the cache, and requests for the resource are satisfied by delivering appropriate parts of one or more segments to the client. When there is a request for entire file, Nginx assembles the response from all segments in the cache and send back to the client.

 

 

Author: , 0000-00-00