Skip to content

Custom Nginx with PageSpeed

linux · server · snippets · By Madhurendra Sachan · (updated )

Pulling nginx from source, customizing & auto updating across servers is a pain, We use pagespeed & custom header modules across all our servers, it autominifies resources & increases page performance without giving pain.

Below is script we use :

#!/bin/bash
NGNX_VER=1.11.1
OPENSSL_VER=1.0.2i
NPS_VERSION=1.11.33.3
#install dependecies
suod apt-get install libpcre3 libpcre3-dev checkinstall zlib1g-dev -y 
sudo apt-get build-dep nginx -y


#download nginx
wget http://nginx.org/download/nginx-${NGNX_VER}.tar.gz
tar zxf nginx-${NGNX_VER}.tar.gz
cd nginx-${NGNX_VER}

#pagespeed module
wget https://github.com/pagespeed/ngx_pagespeed/archive/release-${NPS_VERSION}-beta.zip -O release-${NPS_VERSION}-beta.zip
unzip release-${NPS_VERSION}-beta.zip
cd ngx_pagespeed-release-${NPS_VERSION}-beta/
wget https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz
tar -xzvf ${NPS_VERSION}.tar.gz  # extracts to psol/
cd ..

#download openssl
wget https://www.openssl.org/source/openssl-${OPENSSL_VER}.tar.gz
tar -xzvf openssl-${OPENSSL_VER}.tar.gz


# not using this because it uses dev releases/
#git clone https://github.com/openssl/openssl.git


git clone https://github.com/FRiCKLE/ngx_cache_purge.git
git clone git://github.com/alibaba/nginx-http-concat.git
git clone https://github.com/openresty/headers-more-nginx-module.git


#configure
./configure --prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--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=www-data \
--group=www-data \
--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_sub_module \
--with-mail \
--with-mail_ssl_module \
--with-http_v2_module \
--with-file-aio \
--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 \
--with-debug \
--with-openssl=openssl-${OPENSSL_VER} \
--add-module=ngx_pagespeed-release-${NPS_VERSION}-beta/ \
--add-module=ngx_cache_purge \
--add-module=nginx-http-concat \
--add-module=headers-more-nginx-module 

#compile
make

#build package
checkinstall --install=no -y 

To reduce pain of updating we put it on cdn http://cdn.tik.co/s/general(custom_nginx).sh which can be used as

curl -S "cdn.tik.co/s/general(custom_nginx).sh" | bash

IOT Push Button (Like Amazon Dash)

Amazon Dash button is an incredible piece of hardware and another example of “applied engineering” in Amazon, just like Kindle. The inspiration for this project isn’t directly derived from amazon dash, I wasn’t aware of it until I started digging the internet but at end, I had to set the performance goal to Amazon dash, because

arduino · linux · server · snippets ·

Cheap BLE : JDY-08

Disclaimer : This post is based on my experience which is completely subjective, in no way I am promoting any application or product 😉 I have been trying to get my hands into BLE4.0 modules since long. As always I was looking for small, cheap solution, JDY-08 was one of solution I came across –

arduino · linux ·

Adding a display over network !

You are doomed if your laptop has only one HDMI Port & you are running Linux in that box. Unlike windows – where there are tons of easy to run solution, & there are still tons of solutions if you have big numbers in your pocket. Certainly – I neither wish to spend money on external VGA/HDMI

linux · server · snippets ·