docker image作るやつはあらゆるところにありそうだけど、どうもうまく動かないのよね。ここにメモ。
reference
https://github.com/sickp/docker-alpine-nginx/blob/master/versions/1.17.1-r1/Dockerfile
編集するのは以下
NGINX_VERSION
-
--with-http_stub_status_module
らへんに追加したいモジュールを行追加
Dockerfile
gist https://gist.github.com/kujiy/75b13e140c960afc72281a7bbf8df4f8
FROM alpine:3.10.1
LABEL maintainer "Adrian B. Danieli - https://github.com/sickp"
EXPOSE 80 443
CMD ["nginx", "-g", "daemon off;"]
ENV NGINX_VERSION 1.19.1
RUN set -ex \
&& apk add --no-cache \
ca-certificates \
libressl \
pcre \
zlib \
&& apk add --no-cache --virtual .build-deps \
build-base \
linux-headers \
libressl-dev \
pcre-dev \
wget \
zlib-dev \
&& cd /tmp \
&& wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz \
&& tar xzf nginx-${NGINX_VERSION}.tar.gz \
&& cd /tmp/nginx-${NGINX_VERSION} \
&& ./configure \
\
--with-debug \
\
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
\
--user=nginx \
--group=nginx \
\
--with-threads \
\
--with-file-aio \
\
--with-http_ssl_module \
--with-http_v2_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_auth_request_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_slice_module \
--with-http_stub_status_module \
\
--http-log-path=/var/log/nginx/access.log \
--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-mail \
--with-mail_ssl_module \
\
--with-stream \
--with-stream_ssl_module \
--with-stream_realip_module \
&& make -j$(getconf _NPROCESSORS_ONLN) \
&& make install \
&& sed -i -e 's/#access_log logs\/access.log main;/access_log \/dev\/stdout;/' -e 's/#error_log logs\/error.log notice;/error_log stderr notice;/' /etc/nginx/nginx.conf \
&& adduser -D nginx \
&& mkdir -p /var/cache/nginx \
&& apk del .build-deps \
&& rm -rf /tmp/*
docker-compose.yml
version: '3'
services:
reverseproxy:
build:
context: .
container_name: test
ports:
- 82:80
restart: always
volumes:
- ./nginx:/etc/nginx
logging:
options:
max-size: "1m"
max-file: "10"
./nginx
には nginx official imageからコピってきた /etc/nginx
が入ってます。
nginx posts
nginxのstatusを表示するモジュール /nginx_status
https://qiita.com/uturned0/items/b4eb6839d75050933c7f
nginxにモジュールを追加できるDockerfile
https://qiita.com/uturned0/items/3a0a7cb971edac40b11e
nginxリバプロで header を cookieに書き込む方法
https://qiita.com/uturned0/items/112b8faba403bd534d5c
nginxリバプロで、requestに入っているheaderをlogに出す方法
https://qiita.com/uturned0/items/31162eeb03af05c7dc4b
nginxだけでコンテンツを返す方法 - Load balancerのhealth checkに
https://qiita.com/uturned0/items/a8bcca111b75c5055ed9