Skip to content

Instantly share code, notes, and snippets.

@kuoruan
Last active March 22, 2017 10:15
Show Gist options
  • Save kuoruan/3710b34e0ca206c40d9d0ddbb9e15b40 to your computer and use it in GitHub Desktop.
Save kuoruan/3710b34e0ca206c40d9d0ddbb9e15b40 to your computer and use it in GitHub Desktop.

Install libbrotli

sudo apt-get install autoconf libtool libpcre3-dev zlib1g-dev

git clone https://github.com/bagder/libbrotli
cd libbrotli

./autogen.sh

./configure
make
sudo make install

Install libsodium

wget https://download.libsodium.org/libsodium/releases/LATEST.tar.gz
tar zxf LATEST.tar.gz
cd libsodium*
./configure
make && make install
 
echo /usr/local/lib > /etc/ld.so.conf.d/usr_local_lib.conf
ldconfig

Download brotli

git clone https://github.com/google/ngx_brotli.git

Download Openssl

wget https://www.openssl.org/source/openssl-1.0.2-latest.tar.gz

Openssl ChaCha20 Patch

git clone https://github.com/cloudflare/sslconfig.git

Download Nginx-ct

git clone https://github.com/grahamedgecombe/nginx-ct.git

Download Other Module

git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module.git
git clone https://github.com/cuber/ngx_http_google_filter_module.git
git clone https://github.com/yaoweibin/nginx_limit_speed_module.git
git clone https://github.com/openresty/headers-more-nginx-module.git

Build Nginx

--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=nobody \
--group=nogroup \
--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_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--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 \
--add-module=../ngx_http_substitutions_filter_module \
--add-module=../ngx_http_google_filter_module \
--add-module=../headers-more-nginx-module \
--add-module=../nginx_limit_speed_module \
--add-module=../ngx_brotli \
--add-module=../nginx-ct \
--with-openssl=../openssl

Plugin

https://github.com/loveshell/ngx_lua_waf

SystemCtl Script

vi /lib/systemd/system/nginx.service
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target
systemctl enable nginx.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment