forked from tiredofit/docker-nginx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.debian
159 lines (155 loc) · 8.12 KB
/
Dockerfile.debian
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
ARG DISTRO=debian
ARG DISTRO_VARIANT=bookworm
FROM docker.io/tiredofit/${DISTRO}:${DISTRO_VARIANT}
LABEL maintainer="Dave Conroy (dave at tiredofit dot ca)"
ARG NGINX_VERSION
ENV NGINX_VERSION=${NGINX_VERSION:-"1.25.1"} \
NGINX_AUTH_LDAP_VERSION=master \
NGINX_BROTLI_VERSION=6e975bcb015f62e1f303054897783355e2a877dc \
NGINX_USER=nginx \
NGINX_GROUP=www-data \
NGINX_WEBROOT=/www/html \
IMAGE_NAME="tiredofit/nginx" \
IMAGE_REPO_URL="https://github.com/tiredofit/docker-nginx/"
RUN source /assets/functions/00-container && \
set -x && \
adduser --disabled-password --system --home /var/cache/nginx --shell /sbin/nologin -u 80 --ingroup ${NGINX_GROUP} ${NGINX_USER} && \
package update && \
package upgrade && \
package install \
build-essential \
git \
software-properties-common \
inotify-tools \
perl \
libperl-dev \
libgd3 \
libgd-dev \
libgeoip1 \
libgeoip-dev \
geoip-bin \
libxml2 \
libxml2-dev \
libxslt1.1 \
libxslt1-dev \
libpcre3 \
libpcre3-dev \
zlib1g \
zlib1g-dev \
openssl \
libssl-dev \
libldap2-dev \
&& \
\
mkdir -p /www /var/log/nginx && \
chown -R ${NGINX_USER}:${NGINX_GROUP} /var/log/nginx && \
clone_git_repo https://github.com/openresty/headers-more-nginx-module && \
clone_git_repo https://github.com/kvspb/nginx-auth-ldap ${NGINX_LDAP_VERSION} && \
clone_git_repo https://github.com/AirisX/nginx_cookie_flag_module && \
clone_git_repo https://github.com/google/ngx_brotli ${NGINX_BROTLI_VERSION} && \
mkdir -p /usr/src/nginx && \
curl -sSL http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz | tar xvfz - --strip 1 -C /usr/src/nginx && \
cd /usr/src/nginx && \
./configure --prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--modules-path=/usr/lib/nginx/modules \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/dev/null \
--http-log-path=/dev/null \
--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_USER} \
--group=${NGINX_GROUP} \
--add-module=${GIT_REPO_SRC_NGINX_AUTH_LDAP} \
--add-module=${GIT_REPO_SRC_NGX_BROTLI} \
--add-module=${GIT_REPO_SRC_NGINX_COOKIE_FLAG_MODULE} \
--add-module=${GIT_REPO_SRC_HEADERS_MORE_NGINX_MODULE} \
## GCC 11.2 fix https://github.com/google/ngx_brotli/issues/124
--with-cc-opt='-Wno-vla-parameter' \
--with-compat \
--with-file-aio \
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_geoip_module=dynamic \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_image_filter_module=dynamic \
--with-http_mp4_module \
--with-http_perl_module=dynamic \
--with-http_random_index_module \
--with-http_realip_module \
--with-http_secure_link_module \
--with-http_slice_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_v2_module \
--with-http_xslt_module=dynamic \
--with-mail \
--with-mail_ssl_module \
--with-stream \
--with-stream_geoip_module=dynamic \
--with-stream_realip_module \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-threads \
# --with-quiche=/usr/src/quiche \
# --with-http_v3_module \
&& \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install && \
rm -rf /etc/nginx/html/ && \
mkdir -p /etc/nginx/sites.enabled && \
mkdir -p /etc/nginx/sites.available && \
mkdir -p /usr/share/nginx/html/ && \
install -m644 html/index.html /usr/share/nginx/html/ && \
install -m644 html/50x.html /usr/share/nginx/html/ && \
ln -s ../../usr/lib/nginx/modules /etc/nginx/modules && \
strip /usr/sbin/nginx* && \
strip /usr/lib/nginx/modules/*.so && \
mkdir -p /etc/nginx/snippets/blockbots && \
mkdir -p /etc/nginx/snippets/blockbots-custom && \
curl -sSLk https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/bots.d/bad-referrer-words.conf -o /etc/nginx/snippets/blockbots/bad-referrer-words.conf && \
curl -sSLk https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/bots.d/bad-referrers.conf -o /etc/nginx/snippets/blockbots/bad-referrers.conf && \
curl -sSLk https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/bots.d/blacklist-ips.conf -o /etc/nginx/snippets/blockbots/blacklist-ips.conf && \
curl -sSLk https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/bots.d/blacklist-user-agents.conf -o /etc/nginx/snippets/blockbots/blacklist-user-agents.conf && \
curl -sSLk https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/bots.d/blockbots.conf -o /etc/nginx/snippets/blockbots/blockbots.conf && \
curl -sSLk https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/bots.d/custom-bad-referrers.conf -o /etc/nginx/snippets/blockbots/custom-bad-referrers.conf && \
curl -sSLk https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/bots.d/ddos.conf -o /etc/nginx/snippets/blockbots/ddos.conf && \
curl -sSLk https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/bots.d/whitelist-domains.conf -o /etc/nginx/snippets/blockbots/whitelist-domains.conf && \
curl -sSLk https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/bots.d/whitelist-ips.conf -o /etc/nginx/snippets/blockbots/whitelist-ips.conf && \
curl -sSLk https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/conf.d/globalblacklist.conf -o /etc/nginx/snippets/blockbots/globalblacklist.conf && \
sed -i "s|/etc/nginx/bots.d/|/etc/nginx/snippets/blockbots/|g" /etc/nginx/snippets/blockbots/globalblacklist.conf && \
sed -i "s|/etc/nginx/snippets/blockbots/bad-referrer-words.conf|/etc/nginx/snippets/blockbots-custom/bad-referrer-words.conf|g" /etc/nginx/snippets/blockbots/globalblacklist.conf && \
sed -i "s|/etc/nginx/snippets/blockbots/blacklist-ips.conf|/etc/nginx/snippets/blockbots-custom/blacklist-ips.conf|g" /etc/nginx/snippets/blockbots/globalblacklist.conf && \
sed -i "s|/etc/nginx/snippets/blockbots/blacklist-user-agents.conf|/etc/nginx/snippets/blockbots-custom/blacklist-user-agents.conf|g" /etc/nginx/snippets/blockbots/globalblacklist.conf && \
sed -i "s|/etc/nginx/snippets/blockbots/whitelist-domains.conf|/etc/nginx/snippets/blockbots-custom/whitelist-domains.conf|g" /etc/nginx/snippets/blockbots/globalblacklist.conf && \
sed -i "s|/etc/nginx/snippets/blockbots/whitelist-ips.conf|/etc/nginx/snippets/blockbots-custom/whitelist-ips.conf|g" /etc/nginx/snippets/blockbots/globalblacklist.conf && \
package remove \
build-essential \
git \
libgd-dev \
libgeoip-dev \
libldap2-dev \
libperl-dev \
libpcre3-dev \
libssl-dev \
libxml2-dev \
libxslt1-dev \
zlib1g-dev \
&& \
package cleanup && \
rm -rf \
/etc/nginx/*.default \
/usr/src/* \
/var/log/* \
/var/tmp/*
EXPOSE 80
COPY install /