Skip to content

digitalcube/amimoto-nginx_mainline_for_amazon_linux

Repository files navigation

Nginx mainline for Amazon Linux 1 and 2 with ngx_mruby

CircleCI

includes

  • TLS1.3 support (amzn2)
  • ngx_mruby
  • ngx_cache_purge

Setup

$ sudo yum -y update
$ sudo yum -y install rpm-build git gcc make autoconf
$ git clone https://github.com/OpsRockin/nginx_preview_for_amimoto.git ~/rpmbuild

Update Steps

  • edit nginx_version
    • mod NGINX_VERSION
    • mod OPENSSL_VERSION (optional)
  • edit SPECS/nginx.spec
    • mod Version, Release
    • mod openssl_version (optional)
    • mod ngx_mruby_rev (optional)
    • append note to %changelog section

Build

on EC2 (DEPRECATED)

$ source ./nginx_version
$ source ./NPS_VERSION
$ source ./OPENSSL_VERSION
$ cd ~/rpmbuild
$ sudo yum -y install pcre-devel openssl-devel libxml2-devel libxslt-devel gd-devel perl-devel perl-ExtUtils-Embed geoip-devel gperftools-devel
$ wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz -O SOURCES/nginx-${NGINX_VERSION}.tar.gz
$ wget https://github.com/OpsRockin/ngx_cache_purge/archive/2.3.dynamic.tar.gz -O SOURCES/ngx_cache_purge_2.3.dynamic.tar.gz
$ rpmbuild -ba SPECS/nginx.spec

or Docker (Current maintenance target)

source ./nginx_version
source ./OPENSSL_VERSION
wget https://www.openssl.org/source/openssl-${OPENSSL_VERSION}${OPENSSL_SUBVERSION}.tar.gz -O SOURCES/openssl-${OPENSSL_VERSION}-latest.tar.gz
wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz -O SOURCES/nginx-${NGINX_VERSION}.tar.gz
wget https://github.com/OpsRockin/ngx_cache_purge/archive/2.3.dynamic.tar.gz -O SOURCES/ngx_cache_purge_2.3.dynamic.tar.gz
docker pull amazonlinux:2018.03-with-sources # to update base
docker pull amazonlinux:2-with-sources # to update base
docker build -t local/nginx_preview_for_amimoto:1 --build-arg BASE_TAG=2018.03-with-sources .
docker build -t local/nginx_preview_for_amimoto:2 .

docker run -it --rm -v `pwd`:/root/rpmbuild:cached local/nginx_preview_for_amimoto:1
docker run -it --rm -v `pwd`:/root/rpmbuild:cached local/nginx_preview_for_amimoto:2

Dynamic Modules

Add nginx.conf to enable module below.

load_module modules/ngx_http_mruby_module.so;

example

location /hello {
    mruby_content_handler_code '
        Nginx.rputs "hello"
        Nginx.echo "world!"
    ';
}

Notice: we include forked version to build as dynamic module.

Add nginx.conf to enable module below.

load_module modules/ngx_http_cache_purge_module.so;