Skip to content

Commit 420bf10

Browse files
committed
Docker nginx 🐳 πŸ‘Œ
0 parents  commit 420bf10

File tree

7 files changed

+202
-0
lines changed

7 files changed

+202
-0
lines changed

β€ŽDockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM ubuntu:14.04
2+
3+
ENV NGINX_VERSION=1.8.0
4+
ENV PATH=$PATH:/usr/share/nginx/sbin/
5+
6+
ADD ./install /tmp/nginx-install
7+
ADD ./install.sh /tmp/install.sh
8+
9+
RUN apt-get -qq update && \
10+
apt-get -qq install -y wget && \
11+
cd /tmp/nginx-install && \
12+
/tmp/install.sh && \
13+
rm -rf /tmp/nginx-install && \
14+
rm /tmp/install.sh && \
15+
cp /etc/nginx/nginx.conf /etc/nginx/conf.d/nginx.conf && \
16+
echo "include /etc/nginx/conf.d/*.conf;" > /etc/nginx/nginx.conf
17+
18+
ADD ./start.sh /start.sh
19+
20+
VOLUME /etc/nginx/conf.d
21+
EXPOSE 80 443
22+
CMD /start.sh

β€ŽREADME.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
# Docker NGINX
3+
4+
## Modules
5+
6+
- [headers-more-nginx-module](https://github.com/openresty/headers-more-nginx-module)
7+
- [ngx_http_substitutions_filter_module](https://github.com/yaoweibin/ngx_http_substitutions_filter_module)
8+
- [echo-nginx-module](https://github.com/openresty/echo-nginx-module)
9+
- [nginx_upstream_check_module](https://github.com/yaoweibin/nginx_upstream_check_module)
10+
- [ngx_pagespeed](https://github.com/pagespeed/ngx_pagespeed)
11+
12+
## Pull
13+
14+
```
15+
docker pull igloo/nginx
16+
```
17+
Tags: https://hub.docker.com/r/igloo/nginx/tags/
18+
19+
## Run
20+
21+
```
22+
docker run --rm -ti \
23+
--name nginx \
24+
-p 80:80 -p 443:443 \
25+
-v pathConfig:/etc/nginx/conf.d \
26+
igloo/nginx
27+
```

β€Žinstall.sh

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
##################
6+
# VARS
7+
##################
8+
9+
if [ -z $NGINX_VERSION ]
10+
then
11+
echo 'NGINX_VERSION is undefined'
12+
exit 1
13+
fi
14+
15+
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
16+
17+
NGINXPKG="http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz"
18+
NGINXHEADERSMORE="https://github.com/openresty/headers-more-nginx-module/archive/v0.26.tar.gz"
19+
NGINXFILTER="https://github.com/yaoweibin/ngx_http_substitutions_filter_module/archive/v0.6.4.tar.gz"
20+
NGINXECHO="https://github.com/openresty/echo-nginx-module/archive/v0.57.tar.gz"
21+
NGINXUPSTREAM="https://github.com/yaoweibin/nginx_upstream_check_module.git"
22+
NPS_VERSION=1.9.32.3
23+
NGINXPAGESPEED="https://github.com/pagespeed/ngx_pagespeed/archive/v${NPS_VERSION}-beta.tar.gz"
24+
25+
##################
26+
# FCT
27+
##################
28+
29+
function getPackage() {
30+
mkdir $2
31+
curl -L# $1 | tar -zx --strip 1 -C $2
32+
}
33+
34+
##################
35+
# BEGIN
36+
##################
37+
38+
cd
39+
mkdir -p nginx_install && cd nginx_install
40+
41+
# Install pkgs
42+
apt-get -qq update && \
43+
apt-get -qq install -y \
44+
curl build-essential libpcre3-dev libgeoip-dev libssl-dev \
45+
git \
46+
zlib1g-dev libpcre3 unzip
47+
48+
# Get nginx and prepare modules
49+
getPackage $NGINXPKG nginx
50+
getPackage $NGINXHEADERSMORE headersmore
51+
getPackage $NGINXFILTER substitution
52+
getPackage $NGINXECHO nginxecho
53+
git clone $NGINXUPSTREAM `pwd`/nginxupstream
54+
getPackage $NGINXPAGESPEED nginxpagespeed
55+
56+
cd nginxpagespeed
57+
wget --quiet https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz
58+
tar -xzf ${NPS_VERSION}.tar.gz
59+
cd ..
60+
61+
# Build
62+
cd nginx
63+
/usr/bin/patch -p1 < ../nginxupstream/check_1.7.5+.patch && \
64+
./configure --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2' \
65+
--with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' \
66+
--prefix=/usr/share/nginx \
67+
--conf-path=/etc/nginx/nginx.conf \
68+
--http-log-path=/var/log/nginx/access.log \
69+
--error-log-path=/var/log/nginx/error.log \
70+
--lock-path=/var/lock/nginx.lock \
71+
--pid-path=/run/nginx.pid \
72+
--with-debug \
73+
--with-pcre-jit \
74+
--with-ipv6 \
75+
--with-http_ssl_module \
76+
--with-http_stub_status_module \
77+
--with-http_realip_module \
78+
--with-http_auth_request_module \
79+
--with-http_gzip_static_module \
80+
--without-http_browser_module \
81+
--without-http_geo_module \
82+
--without-http_memcached_module \
83+
--without-http_referer_module \
84+
--without-http_scgi_module \
85+
--without-http_split_clients_module \
86+
--without-http_ssi_module \
87+
--without-http_userid_module \
88+
--without-http_uwsgi_module \
89+
--add-module=../headersmore/ \
90+
--add-module=../substitution/ \
91+
--add-module=../nginxecho/ \
92+
--add-module=../nginxupstream/ \
93+
--add-module=../nginxpagespeed/ \
94+
--with-http_flv_module \
95+
--with-mail \
96+
--with-http_geoip_module \
97+
--with-http_spdy_module && \
98+
make && make install
99+
100+
STATUS=$?
101+
102+
if [ $STATUS -eq 0 ]
103+
then
104+
105+
cp -r $DIR/nginx-install/geoip /etc/nginx/
106+
cp $DIR/nginx-install/nginx-logrotate /etc/logrotate.d/nginx
107+
mkdir -p /etc/nginx/conf.d
108+
109+
# Clean install directory
110+
rm -rf $HOME/nginx_install
111+
112+
echo 'NGINX VERSION: ' && `/usr/share/nginx/sbin/nginx -v`
113+
else
114+
echo 'Error...'
115+
exit 1
116+
fi
117+
118+
exit 0

β€Žinstall/geoip/GeoIP.dat

570 KB
Binary file not shown.

β€Žinstall/geoip/GeoLiteCity.dat

15.1 MB
Binary file not shown.

β€Žinstall/nginx-logrotate

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
/var/log/nginx/*.log {
3+
4+
# rotate the logfile(s) daily
5+
daily
6+
7+
# adds extension like YYYYMMDD instead of simply adding a number
8+
dateext
9+
10+
# If log file is missing, go on to next one without issuing an error msg
11+
missingok
12+
13+
# Save logfiles for the last 10 days
14+
rotate 10
15+
16+
# Old versions of log files are compressed with gzip
17+
compress
18+
19+
# Postpone compression of the previous log file to the next rotation cycle
20+
delaycompress
21+
22+
# Do not rotate the log if it is empty
23+
notifempty
24+
25+
# After logfile is rotated and nginx.pid exists, send the USR1 signal
26+
postrotate
27+
[ ! -f /run/nginx.pid ] || kill -USR1 `cat /run/nginx.pid`
28+
endscript
29+
30+
}
31+

β€Žstart.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
nginx && tail -f /var/log/nginx/access.log /var/log/nginx/error.log

0 commit comments

Comments
Β (0)