-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.without-modsec
150 lines (132 loc) · 5.27 KB
/
Dockerfile.without-modsec
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
FROM alpine:latest as build
ARG BUILD
ARG NGX_MAINLINE_VER=1.27.0
ARG QUICTLS_VER=openssl-3.3.0+quic
ARG NGX_BROTLI=master
ARG NGX_HEADERS_MORE=v0.37rc1
ARG NGX_NJS=0.8.5
ARG NGX_GEOIP2=3.4
WORKDIR /src
# Install the required packages
RUN apk add --no-cache \
ca-certificates \
build-base \
patch \
cmake \
git \
libtool \
autoconf \
automake \
libatomic_ops-dev \
zlib-dev \
pcre2-dev \
linux-headers \
libxml2-dev \
libxslt-dev \
perl-dev \
curl-dev \
geoip-dev \
libmaxminddb-dev
RUN git clone --recursive --branch "$QUICTLS_VER" https://github.com/quictls/openssl /src/openssl
# Modules
RUN (git clone --recursive --branch "$NGX_BROTLI" https://github.com/google/ngx_brotli /src/ngx_brotli \
&& git clone --recursive --branch "$NGX_HEADERS_MORE" https://github.com/openresty/headers-more-nginx-module /src/headers-more-nginx-module \
&& git clone --recursive --branch "$NGX_NJS" https://github.com/nginx/njs /src/njs \
&& git clone --recursive --branch "$NGX_GEOIP2" https://github.com/leev/ngx_http_geoip2_module /src/ngx_http_geoip2_module)
# Nginx
RUN (wget https://nginx.org/download/nginx-"$NGX_MAINLINE_VER".tar.gz -O - | tar xzC /src \
&& mv /src/nginx-"$NGX_MAINLINE_VER" /src/nginx \
&& wget https://raw.githubusercontent.com/nginx-modules/ngx_http_tls_dyn_size/master/nginx__dynamic_tls_records_1.25.1%2B.patch -O /src/nginx/dynamic_tls_records.patch \
&& sed -i "s|nginx/|NGINX-QuicTLS without ModSec/|g" /src/nginx/src/core/nginx.h \
&& sed -i "s|Server: nginx|Server: NGINX-QuicTLS without ModSec|g" /src/nginx/src/http/ngx_http_header_filter_module.c \
&& sed -i "s|<hr><center>nginx</center>|<hr><center>NGINX-QuicTLS without ModSec</center>|g" /src/nginx/src/http/ngx_http_special_response.c \
&& cd /src/nginx \
&& patch -p1 < dynamic_tls_records.patch)
RUN cd /src/nginx \
&& ./configure \
--build=${BUILD} \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--modules-path=/usr/lib/nginx/modules \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--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 \
--user=nginx \
--group=nginx \
--with-compat \
--with-threads \
--with-file-aio \
--with-libatomic \
--with-pcre \
--without-poll_module \
--without-select_module \
--with-openssl="/src/openssl" \
--with-openssl-opt="no-ssl3 no-ssl3-method no-weak-ssl-ciphers" \
--with-mail=dynamic \
--with-mail_ssl_module \
--with-stream=dynamic \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-stream_realip_module \
--with-stream_geoip_module=dynamic \
--with-http_v2_module \
--with-http_v3_module \
--with-http_ssl_module \
--with-http_perl_module=dynamic \
--with-http_geoip_module=dynamic \
--with-http_realip_module \
--with-http_gunzip_module \
--with-http_addition_module \
--with-http_gzip_static_module \
--with-http_auth_request_module \
--add-dynamic-module=/src/ngx_brotli \
--add-dynamic-module=/src/headers-more-nginx-module \
--add-dynamic-module=/src/njs/nginx \
--add-dynamic-module=/src/ngx_http_geoip2_module \
&& make -j "$(nproc)" \
&& make -j "$(nproc)" install \
&& rm /src/nginx/*.patch \
&& strip -s /usr/sbin/nginx \
&& strip -s /usr/lib/nginx/modules/*.so
FROM alpine:latest
COPY --from=build /etc/nginx /etc/nginx
COPY --from=build /usr/sbin/nginx /usr/sbin/nginx
COPY --from=build /usr/lib/nginx /usr/lib/nginx
COPY --from=build /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=build /usr/lib/perl5/core_perl/perllocal.pod /usr/lib/perl5/core_perl/perllocal.pod
COPY assets/nginx.conf /etc/nginx/nginx.conf
COPY assets/default.conf /etc/nginx/conf.d/default.conf
COPY assets/index.html /etc/nginx/html/index.html
RUN addgroup -S nginx \
&& adduser -D -S -h /var/cache/nginx -s /sbin/nologin -G nginx nginx
RUN apk add --no-cache \
ca-certificates \
tzdata \
tini \
zlib \
pcre2 \
libstdc++ \
libxml2 \
libxslt \
perl \
libcurl \
geoip \
libmaxminddb-libs
RUN mkdir -p /var/log/nginx/ \
&& touch /var/log/nginx/access.log \
&& touch /var/log/nginx/error.log \
&& ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log \
&& ln -s /usr/lib/nginx/modules /etc/nginx/modules \
&& sed -i "s|#load_module modules/ngx_http_modsecurity_module.so;||g" /etc/nginx/nginx.conf
LABEL maintainer="Bence Kócsi <[email protected]>"
EXPOSE 80 443 443/udp
ENTRYPOINT ["tini", "--", "nginx"]
CMD ["-g", "daemon off;"]