forked from openbridge/nginx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
executable file
·209 lines (203 loc) · 7.33 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
FROM alpine:3.12
MAINTAINER Thomas Spicer ([email protected])
ARG NGINX_VERSION
ENV VAR_PREFIX=/var/run \
LOG_PREFIX=/var/log/nginx \
TEMP_PREFIX=/tmp \
CACHE_PREFIX=/var/cache \
CONF_PREFIX=/etc/nginx \
CERTS_PREFIX=/etc/pki/tls
RUN set -x \
&& CONFIG="\
--prefix=/usr/share/nginx/ \
--sbin-path=/usr/sbin/nginx \
--add-module=/tmp/naxsi/naxsi_src \
--modules-path=/usr/lib/nginx/modules \
--conf-path=${CONF_PREFIX}/nginx.conf \
--error-log-path=${LOG_PREFIX}/error.log \
--http-log-path=${LOG_PREFIX}/access.log \
--pid-path=${VAR_PREFIX}/nginx.pid \
--lock-path=${VAR_PREFIX}/nginx.lock \
--http-client-body-temp-path=${TEMP_PREFIX}/client_temp \
--http-proxy-temp-path=${TEMP_PREFIX}/proxy_temp \
--http-fastcgi-temp-path=${TEMP_PREFIX}/fastcgi_temp \
--http-uwsgi-temp-path=${TEMP_PREFIX}/uwsgi_temp \
--http-scgi-temp-path=${TEMP_PREFIX}/scgi_temp \
--user=www-data \
--group=www-data \
--with-http_ssl_module \
--with-pcre-jit \
--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_xslt_module=dynamic \
--with-http_image_filter_module=dynamic \
--with-http_geoip_module=dynamic \
--with-threads \
--with-stream \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-stream_realip_module \
--with-stream_geoip_module=dynamic \
--with-http_slice_module \
--with-mail \
--with-mail_ssl_module \
--with-compat \
--with-file-aio \
--with-http_v2_module \
--add-module=/tmp/ngx_cache_purge-2.3 \
--add-module=/tmp/ngx_http_redis-0.3.9 \
--add-module=/tmp/redis2-nginx-module-0.15 \
--add-module=/tmp/srcache-nginx-module-0.31 \
--add-module=/tmp/echo-nginx-module \
--add-module=/tmp/ngx_devel_kit-0.3.1 \
--add-module=/tmp/set-misc-nginx-module-0.32 \
--add-module=/tmp/ngx_brotli \
--with-ld-opt='-L/usr/lib' \
--with-cc-opt=-Wno-error \
" \
&& addgroup -g 82 -S www-data \
&& adduser -u 82 -D -S -h /var/cache/nginx -s /sbin/nologin -G www-data www-data \
&& apk add --no-cache --virtual .build-deps \
alpine-sdk \
autoconf \
automake \
binutils \
build-base \
build-base \
ca-certificates \
cmake \
findutils \
gcc \
gd-dev \
geoip-dev \
gettext \
git \
gnupg \
gnupg \
go \
gzip \
libc-dev \
libtool \
libxslt-dev \
linux-headers \
libedit-dev \
make \
musl-dev \
openssl-dev \
pcre-dev \
perl-dev \
unzip \
wget \
zlib-dev \
&& apk add --no-cache --update \
curl \
monit \
wget \
bash \
bind-tools \
rsync \
geoip \
openssl \
pcre \
tini \
tar \
&& cd /tmp \
&& git clone https://github.com/google/ngx_brotli --depth=1 \
&& cd ngx_brotli && git submodule update --init \
&& export NGX_BROTLI_STATIC_MODULE_ONLY=1 \
&& cd /tmp \
&& git clone https://github.com/nbs-system/naxsi.git \
&& echo 'adding /usr/local/share/GeoIP/GeoIP.dat database' \
&& wget -N https://raw.githubusercontent.com/openbridge/nginx/master/geoip/GeoLiteCity.dat.gz \
&& wget -N https://raw.githubusercontent.com/openbridge/nginx/master/geoip/GeoIP.dat.gz \
&& gzip -d GeoIP.dat.gz \
&& gzip -d GeoLiteCity.dat.gz \
&& mkdir /usr/local/share/GeoIP/ \
&& mv GeoIP.dat /usr/local/share/GeoIP/ \
&& mv GeoLiteCity.dat /usr/local/share/GeoIP/ \
&& chown -R www-data:www-data /usr/local/share/GeoIP/ \
&& curl -fSL http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz -o nginx.tar.gz \
&& mkdir -p /usr/src \
&& tar -zxC /usr/src -f nginx.tar.gz \
&& rm nginx.tar.gz \
&& cd /tmp \
&& git clone https://github.com/openresty/echo-nginx-module.git \
&& wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.1.zip -O dev.zip \
&& wget https://github.com/openresty/set-misc-nginx-module/archive/v0.32.zip -O setmisc.zip \
&& wget https://people.freebsd.org/~osa/ngx_http_redis-0.3.9.tar.gz \
&& wget https://github.com/openresty/redis2-nginx-module/archive/v0.15.zip -O redis.zip \
&& wget https://github.com/openresty/srcache-nginx-module/archive/v0.31.zip -O cache.zip \
&& wget https://github.com/FRiCKLE/ngx_cache_purge/archive/2.3.zip -O purge.zip \
&& tar -zx -f ngx_http_redis-0.3.9.tar.gz \
&& unzip dev.zip \
&& unzip setmisc.zip \
&& unzip redis.zip \
&& unzip cache.zip \
&& unzip purge.zip \
&& cd /usr/src/nginx-$NGINX_VERSION \
&& ./configure $CONFIG --with-debug \
&& make -j$(getconf _NPROCESSORS_ONLN) \
&& mv objs/nginx objs/nginx-debug \
&& mv objs/ngx_http_xslt_filter_module.so objs/ngx_http_xslt_filter_module-debug.so \
&& mv objs/ngx_http_image_filter_module.so objs/ngx_http_image_filter_module-debug.so \
&& mv objs/ngx_stream_geoip_module.so objs/ngx_stream_geoip_module-debug.so \
&& ./configure $CONFIG \
&& make -j$(getconf _NPROCESSORS_ONLN) \
&& make install \
&& rm -rf /etc/nginx/html/ \
&& mkdir /etc/nginx/conf.d/ \
&& mkdir -p /usr/share/nginx/html/ \
&& install -m644 html/index.html /usr/share/nginx/html/ \
&& install -m644 html/50x.html /usr/share/nginx/html/ \
&& install -m755 objs/nginx-debug /usr/sbin/nginx-debug \
&& install -m755 objs/ngx_http_xslt_filter_module-debug.so /usr/lib/nginx/modules/ngx_http_xslt_filter_module-debug.so \
&& install -m755 objs/ngx_http_image_filter_module-debug.so /usr/lib/nginx/modules/ngx_http_image_filter_module-debug.so \
&& install -m755 objs/ngx_stream_geoip_module-debug.so /usr/lib/nginx/modules/ngx_stream_geoip_module-debug.so \
&& ln -s ../../usr/lib/nginx/modules /etc/nginx/modules \
&& strip /usr/sbin/nginx* \
&& strip /usr/lib/nginx/modules/*.so \
&& mkdir -p /usr/local/bin/ \
&& mkdir -p ${CACHE_PREFIX} \
&& mkdir -p ${CERTS_PREFIX} \
&& mv /usr/bin/envsubst /tmp/ \
&& runDeps="$( \
scanelf --needed --nobanner /tmp/envsubst \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
| sort -u \
| xargs -r apk info --installed \
| sort -u \
)" \
&& apk add --no-cache $runDeps \
&& mv /tmp/envsubst /usr/local/bin/ \
&& cd /etc/pki/tls/ \
&& nice -n +5 openssl dhparam -out /etc/pki/tls/dhparam.pem.default 2048 \
&& apk add --no-cache $runDeps \
&& apk del .build-deps \
&& cd /tmp/naxsi \
&& mv naxsi_config/naxsi_core.rules /etc/nginx/naxsi_core.rules \
&& rm -rf /tmp/* \
&& rm -rf /usr/src/* \
&& ln -sf /dev/stdout ${LOG_PREFIX}/access.log \
&& ln -sf /dev/stderr ${LOG_PREFIX}/error.log \
&& ln -sf /dev/stdout ${LOG_PREFIX}/blocked.log
COPY conf/ /conf
COPY test/ /tmp/test
COPY error/ /tmp/error/
COPY check_wwwdata.sh /usr/bin/check_wwwdata
COPY check_folder.sh /usr/bin/check_folder
COPY check_host.sh /usr/bin/check_host
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh /usr/bin/check_wwwdata /usr/bin/check_folder /usr/bin/check_host
STOPSIGNAL SIGQUIT
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["/usr/sbin/nginx", "-g", "daemon off;"]