Skip to content

Instantly share code, notes, and snippets.

@esurdam
Last active December 2, 2021 02:42
Show Gist options
  • Save esurdam/8bb74fa86db0629202d9c32238b56e4d to your computer and use it in GitHub Desktop.
Save esurdam/8bb74fa86db0629202d9c32238b56e4d to your computer and use it in GitHub Desktop.
Install nginx with alpn support

Install nginx 1.11 with ALPN

Test your web server for HTTP/2 and ALPN support KeyCDN

Test SSL strength of your setup SSL LABS

install openssl with ALPN support

sudo - su
yum group install "Development Tools"
wget https://www.openssl.org/source/openssl-1.0.2-latest.tar.gz
tar xzvf openssl-1.0.2-latest.tar.gz

# cd {{ dir }}
./config
make
make test
make install

openssl version

# if old version persists
mv /usr/bin/openssl /root/
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl

# move new source to /usr/lcoal for nginx conf
cd 
mv {{ dir }} /usr/local

install nginx

This setup includes njs

yum install -y httpd-devel pcre perl pcre-devel zlib zlib-devel GeoIP GeoIP-devel perl-ExtUtils-Embed gd-devel

git clone https://github.com/nginx/njs

wget "https://nginx.org/download/nginx-1.11.2.tar.gz"
tar xzvf nginx-1.11.2.tar.gz
cd nginx-1.11.2

if you want you can change the server name that gets reported to the client ;)

## vi src/http/ngx_http_header_filter_module.c (lines 48 and 49)
static char ngx_http_server_string[] = "Server: MyDomain.com" CRLF;
static char ngx_http_server_full_string[] = "Server: MyDomain.com" CRLF;

now lets configure and install

# remove modules you don't want
./configure --prefix=/etc/nginx\
 --user=nginx --group=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\
 --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\
 --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_auth_request_module\
 --with-http_image_filter_module=dynamic\
 --with-http_geoip_module=dynamic\
 --with-http_perl_module=dynamic\
 --with-http_ssl_module --with-openssl=/usr/local/openssl-1.0.2h\
 --add-dynamic-module=../njs/nginx\
 --with-threads --with-stream --with-stream_ssl_module\
 --with-http_slice_module\
 --with-mail --with-mail_ssl_module\
 --with-file-aio\
 --with-ipv6 --with-http_v2_module\
 --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'	
make
make install
[root@yoo ~]# nginx -V
nginx version: nginx/1.11.2
built by --- (GCC)
built with OpenSSL 1.0.2h  3 May 2016
TLS SNI support enabled
...

Lazy way is to add the following to /etc/yum.repos.d/nginx.repo

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/rhel/6/$basearch/
gpgcheck=0
priority=1
enabled=1

and then

yum install nginx

run nginx -V for verbose output

[root@yoo ~]# nginx -V
nginx version: nginx/1.11.2
built by --- (GCC)
built with OpenSSL 1.0.2h  3 May 2016
TLS SNI support enabled
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment