diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..5eddabf1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,61 @@ +/playground + +# babel dist +/lib + +# Numerous always-ignore extensions +*.bak +*.patch +*.diff +*.err +*.orig +*.log +*.rej +*.swo +*.swp +*.zip +xxxx +*.vi +*~ +*.sass-cache +*.lock +*.rdb +*.db +nohup.out +.nyc_output +coverage.lcov +package-lock.json +*.tgz + +# OS or Editor folders +.DS_Store +._* +.cache +.project +.settings +.tmproj +*.esproj +*.sublime-project +*.sublime-workspace +nbproject +thumbs.db + +# Folders to ignore +.hg +.svn +.CVS +.idea +node_modules +old/ +*-old/ +*-notrack/ +no-track/ +build/ +combo/ +reference/ +jscoverage_lib/ +temp/ +tmp/ + +# codecov.io +coverage/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..e69de29b diff --git a/README.md b/README.md index f0d253c2..93cb6b11 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,20 @@ -# About this Repo + +[![docker](https://img.shields.io/badge/docker-kaelz%2Fnginx-brightgreen.svg)](https://hub.docker.com/r/kaelz/nginx/) + +# kaelz/nginx + +The altered nginx docker image from the official one, which includes [headers-more-nginx-module](https://github.com/openresty/headers-more-nginx-module) + +Only supports `alpine` for now. + +## Usage + +```sh +docker pull kaelz/nginx:alpine +docker run -d -P --name nginx kaelz/nginx:alpine +``` + +**** This is the Git repo of the official Docker image for [nginx](https://registry.hub.docker.com/_/nginx/). See the Hub page for the full readme on how to use the Docker image and for information @@ -6,4 +22,3 @@ regarding contributing and issues. The full readme is generated over in [docker-library/docs](https://github.com/docker-library/docs), specificially in [docker-library/docs/nginx](https://github.com/docker-library/docs/tree/master/nginx). - diff --git a/mainline/alpine/Dockerfile b/mainline/alpine/Dockerfile index cf12377b..613c2817 100644 --- a/mainline/alpine/Dockerfile +++ b/mainline/alpine/Dockerfile @@ -3,6 +3,7 @@ FROM alpine:3.7 LABEL maintainer="NGINX Docker Maintainers " ENV NGINX_VERSION 1.13.8 +ENV HEADERS_MORE_VERSION 0.33 RUN GPG_KEYS=B0F4253373F8F6F510D42178520A9993A1C052F8 \ && CONFIG="\ @@ -49,6 +50,7 @@ RUN GPG_KEYS=B0F4253373F8F6F510D42178520A9993A1C052F8 \ --with-compat \ --with-file-aio \ --with-http_v2_module \ + --add-module=/usr/src/headers-more-nginx-module-$HEADERS_MORE_VERSION \ " \ && addgroup -S nginx \ && adduser -D -S -h /var/cache/nginx -s /sbin/nologin -G nginx nginx \ @@ -66,22 +68,28 @@ RUN GPG_KEYS=B0F4253373F8F6F510D42178520A9993A1C052F8 \ gd-dev \ geoip-dev \ && curl -fSL https://nginx.org/download/nginx-$NGINX_VERSION.tar.gz -o nginx.tar.gz \ - && curl -fSL https://nginx.org/download/nginx-$NGINX_VERSION.tar.gz.asc -o nginx.tar.gz.asc \ - && export GNUPGHOME="$(mktemp -d)" \ - && found=''; \ - for server in \ - ha.pool.sks-keyservers.net \ - hkp://keyserver.ubuntu.com:80 \ - hkp://p80.pool.sks-keyservers.net:80 \ - pgp.mit.edu \ - ; do \ - echo "Fetching GPG key $GPG_KEYS from $server"; \ - gpg --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$GPG_KEYS" && found=yes && break; \ - done; \ - test -z "$found" && echo >&2 "error: failed to fetch GPG key $GPG_KEYS" && exit 1; \ - gpg --batch --verify nginx.tar.gz.asc nginx.tar.gz \ - && rm -r "$GNUPGHOME" nginx.tar.gz.asc \ + && curl -fSL https://nginx.org/download/nginx-$NGINX_VERSION.tar.gz.asc -o nginx.tar.gz.asc \ + \ + # && export GNUPGHOME="$(mktemp -d)" \ + # && found=''; \ + # for server in \ + # ha.pool.sks-keyservers.net \ + # hkp://keyserver.ubuntu.com:80 \ + # hkp://p80.pool.sks-keyservers.net:80 \ + # pgp.mit.edu \ + # ; do \ + # echo "Fetching GPG key $GPG_KEYS from $server"; \ + # gpg --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$GPG_KEYS" && found=yes && break; \ + # done; \ + # test -z "$found" && echo >&2 "error: failed to fetch GPG key $GPG_KEYS" && exit 1; \ + # gpg --batch --verify nginx.tar.gz.asc nginx.tar.gz \ + # && rm -r "$GNUPGHOME" nginx.tar.gz.asc \ && mkdir -p /usr/src \ + \ + # Download headers-more-nginx-module + && curl -fSL https://github.com/openresty/headers-more-nginx-module/archive/v$HEADERS_MORE_VERSION.tar.gz -o headers-more.tar.gz \ + && tar -zxC /usr/src -f headers-more.tar.gz \ + && rm headers-more.tar.gz \ && tar -zxC /usr/src -f nginx.tar.gz \ && rm nginx.tar.gz \ && cd /usr/src/nginx-$NGINX_VERSION \ @@ -95,6 +103,7 @@ RUN GPG_KEYS=B0F4253373F8F6F510D42178520A9993A1C052F8 \ && ./configure $CONFIG \ && make -j$(getconf _NPROCESSORS_ONLN) \ && make install \ + && rm -rf $HEADERS_MORE_HOME \ && rm -rf /etc/nginx/html/ \ && mkdir /etc/nginx/conf.d/ \ && mkdir -p /usr/share/nginx/html/ \ @@ -108,6 +117,7 @@ RUN GPG_KEYS=B0F4253373F8F6F510D42178520A9993A1C052F8 \ && ln -s ../../usr/lib/nginx/modules /etc/nginx/modules \ && strip /usr/sbin/nginx* \ && strip /usr/lib/nginx/modules/*.so \ + && rm -rf /usr/src/headers-more-nginx-module-$HEADERS_MORE_VERSION \ && rm -rf /usr/src/nginx-$NGINX_VERSION \ \ # Bring in gettext so we can get `envsubst`, then throw diff --git a/mainline/alpine/nginx.conf b/mainline/alpine/nginx.conf index e4bad8db..f8ce2592 100644 --- a/mainline/alpine/nginx.conf +++ b/mainline/alpine/nginx.conf @@ -1,4 +1,3 @@ - user nginx; worker_processes 1; @@ -7,26 +6,22 @@ pid /var/run/nginx.pid; events { - worker_connections 1024; + worker_connections 1024; } http { - include /etc/nginx/mime.types; - default_type application/octet-stream; - - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - - access_log /var/log/nginx/access.log main; + include /etc/nginx/mime.types; + default_type application/octet-stream; - sendfile on; - #tcp_nopush on; + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; - keepalive_timeout 65; + access_log /var/log/nginx/access.log main; - #gzip on; + sendfile on; + keepalive_timeout 65; - include /etc/nginx/conf.d/*.conf; + include /etc/nginx/conf.d/*.conf; } diff --git a/mainline/alpine/nginx.vh.default.conf b/mainline/alpine/nginx.vh.default.conf index 299c622a..4727a091 100644 --- a/mainline/alpine/nginx.vh.default.conf +++ b/mainline/alpine/nginx.vh.default.conf @@ -1,45 +1,44 @@ server { - listen 80; - server_name localhost; - - #charset koi8-r; - #access_log /var/log/nginx/host.access.log main; - - location / { - root /usr/share/nginx/html; - index index.html index.htm; - } - - #error_page 404 /404.html; - - # redirect server error pages to the static page /50x.html - # - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root /usr/share/nginx/html; - } - - # proxy the PHP scripts to Apache listening on 127.0.0.1:80 - # - #location ~ \.php$ { - # proxy_pass http://127.0.0.1; - #} - - # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 - # - #location ~ \.php$ { - # root html; - # fastcgi_pass 127.0.0.1:9000; - # fastcgi_index index.php; - # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; - # include fastcgi_params; - #} - - # deny access to .htaccess files, if Apache's document root - # concurs with nginx's one - # - #location ~ /\.ht { - # deny all; - #} + listen 80; + server_name localhost; + + #charset koi8-r; + #access_log /var/log/nginx/host.access.log main; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 + # + # location ~ \.php$ { + # proxy_pass http://127.0.0.1; + # } + # + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + # + # location ~ \.php$ { + # root html; + # fastcgi_pass 127.0.0.1:9000; + # fastcgi_index index.php; + # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; + # include fastcgi_params; + # } + # + # deny access to .htaccess files, if Apache's document root + # concurs with nginx's one + # + # location ~ /\.ht { + # deny all; + # } } - diff --git a/package.json b/package.json new file mode 100644 index 00000000..0e19d450 --- /dev/null +++ b/package.json @@ -0,0 +1,12 @@ +{ + "private": true, + "name": "kaelz/nginx", + "scripts": { + "build": "docker build -t kaelz/nginx:alpine", + "test": , + "test-no-cov": "ava --verbose --timeout=10s" + }, + "devDependencies": { + "ava": "^0.16.0" + } +} diff --git a/test/fixtures/conf.d/default.conf b/test/fixtures/conf.d/default.conf new file mode 100644 index 00000000..391c3d82 --- /dev/null +++ b/test/fixtures/conf.d/default.conf @@ -0,0 +1,10 @@ +server { + listen 80; + server_name localhost; + + location / { + more_clear_headers 'Etag'; + root /usr/share/nginx/html; + index index.html index.htm; + } +} diff --git a/test/fixtures/nginx.conf b/test/fixtures/nginx.conf new file mode 100644 index 00000000..00739ef7 --- /dev/null +++ b/test/fixtures/nginx.conf @@ -0,0 +1,24 @@ +user nginx; +worker_processes 1; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + keepalive_timeout 65; + + include /etc/nginx/conf.d/*.conf; +} diff --git a/test/mainline/alpine/index.js b/test/mainline/alpine/index.js new file mode 100644 index 00000000..d974016d --- /dev/null +++ b/test/mainline/alpine/index.js @@ -0,0 +1 @@ +const test = require('ava')