作者: Ju4t
$ docker pull ju4t/nginxplus
$ docker run --name nginx-plus -p 80:80 -p 443:443 -p 8080:8080 -d ju4t/nginxplus
http://localhost
http://localhost:8080/dashboard.html
# For Debian 9
FROM debian:stretch-slim
LABEL maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>"
# Download certificate and key from the customer portal (https://cs.nginx.com)
# and copy to the build context
COPY nginx-repo.crt /etc/ssl/nginx/
COPY nginx-repo.key /etc/ssl/nginx/
# Install NGINX Plus
RUN set -x \
&& apt-get update && apt-get upgrade -y \
&& apt-get install --no-install-recommends --no-install-suggests -y apt-transport-https ca-certificates gnupg1 \
&& \
NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \
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 $NGINX_GPGKEY from $server"; \
apt-key adv --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \
done; \
test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \
echo "Acquire::https::plus-pkgs.nginx.com::Verify-Peer \"true\";" >> /etc/apt/apt.conf.d/90nginx \
&& echo "Acquire::https::plus-pkgs.nginx.com::Verify-Host \"true\";" >> /etc/apt/apt.conf.d/90nginx \
&& echo "Acquire::https::plus-pkgs.nginx.com::SslCert \"/etc/ssl/nginx/nginx-repo.crt\";" >> /etc/apt/apt.conf.d/90nginx \
&& echo "Acquire::https::plus-pkgs.nginx.com::SslKey \"/etc/ssl/nginx/nginx-repo.key\";" >> /etc/apt/apt.conf.d/90nginx \
&& printf "deb https://plus-pkgs.nginx.com/debian stretch nginx-plus\n" > /etc/apt/sources.list.d/nginx-plus.list \
&& apt-get update && apt-get install -y nginx-plus \
&& apt-get remove --purge --auto-remove -y gnupg1 \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /etc/ssl/nginx
# Forward request logs to Docker log collector
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log
EXPOSE 80 8080 443
STOPSIGNAL SIGTERM
RUN rm -v /etc/nginx/conf.d/*
COPY app.conf /etc/nginx/conf.d/app.conf
CMD ["nginx", "-g", "daemon off;"]
upstream backend {
zone upstream_backend 64k;
state /tmp/upstream.conf;
}
match hello {
status 200;
header Content-Type = text/html;
body ~ "Hello";
}
server {
listen 80;
status_zone backend;
location / {
proxy_pass http://backend;
health_check interval=2s match=hello;
}
}
server {
listen 8080;
root /usr/share/nginx/html;
location /api {
api write=on;
}
location = / {
return 301 /dashboard.html;
}
}
docker build -t ju4t/nginxplus .
https://github.com/nginxinc/NGINX-Demos/