Skip to content

Instantly share code, notes, and snippets.

@benny-shotvibe
Last active November 8, 2015 16:58
Show Gist options
  • Save benny-shotvibe/04c930120e18c54eab44 to your computer and use it in GitHub Desktop.
Save benny-shotvibe/04c930120e18c54eab44 to your computer and use it in GitHub Desktop.
Patched version of nginx

We are using a patched version of nginx that does not erase the "ETag" http header for gzipped responses.

See: https://forum.nginx.org/read.php?2,240120,240120#msg-240120

This is what was done:

To compile nginx, the PCRE library is needed. Here is how it was installed:

$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.gz
$ tar -zxvf pcre-8.37.tar.gz
$ cd pcre-8.37
$ ./configure
$ make
$ sudo make install
$ sudo ldconfig

Then nginx was compiled:

$ wget http://nginx.org/download/nginx-1.4.7.tar.gz
$ tar -zxvf nginx-1.4.7.tar.gz
$ cd nginx-1.4.7
$ vim ./src/http/modules/ngx_http_gzip_filter_module.c    

Remove or comment out line 309 which should contain:

ngx_http_clear_etag(r);

Now continue to compile nginx. An attempt was made to configure nginx with the same settings as the default Ubuntu package.

I took the flags from the config.status.full build flags from here(removing some flags that aren't needed): https://launchpadlibrarian.net/162154627/buildlog_ubuntu-raring-amd64.nginx_1.4.4-4~raring_UPLOADING.txt.gz

$ ./configure  \
    --prefix=/usr/share/nginx \
    --conf-path=/etc/nginx/nginx.conf \
    --error-log-path=/var/log/nginx/error.log \
    --http-client-body-temp-path=/var/lib/nginx/body \
    --http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
    --http-log-path=/var/log/nginx/access.log \
    --http-proxy-temp-path=/var/lib/nginx/proxy \
    --http-scgi-temp-path=/var/lib/nginx/scgi \
    --http-uwsgi-temp-path=/var/lib/nginx/uwsgi \
    --lock-path=/var/lock/nginx.lock \
    --pid-path=/run/nginx.pid \
    --with-pcre-jit \
    --with-debug \
    --with-http_addition_module \
    --with-http_dav_module \
    --with-http_gzip_static_module \
    --with-http_realip_module \
    --with-http_spdy_module \
    --with-http_stub_status_module \
    --with-http_ssl_module \
    --with-http_sub_module \
    --with-ipv6 \
    --with-mail \
    --with-mail_ssl_module
$ make
$ strip ./objs/nginx

Then we replace the system nginx executable that was installed from the Ubuntu system package with the exeuctable that we just compiled.

$ sudo mv /usr/sbin/nginx /usr/sbin/nginx.bak
$ sudo cp ./objs/nginx /usr/sbin/nginx

Restart the nginx server

$ sudo service nginx restart

If there were problems with the restart then try this:

$ sudo killall nginx
$ sudo service nginx restart

Good luck!

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