diff options
-rw-r--r-- | Dockerfile | 42 | ||||
-rw-r--r-- | LICENSE | 22 | ||||
-rw-r--r-- | circle.yml | 13 | ||||
-rw-r--r-- | nginx.conf | 31 | ||||
-rw-r--r-- | nginx.service | 62 |
5 files changed, 170 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5f09195 --- /dev/null +++ b/Dockerfile | |||
@@ -0,0 +1,42 @@ | |||
1 | FROM ubuntu:latest | ||
2 | MAINTAINER clarkzjw <[email protected]> | ||
3 | |||
4 | # Install Ubuntu and base software. | ||
5 | RUN \ | ||
6 | sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && \ | ||
7 | apt-get update && \ | ||
8 | apt-get -y -qq upgrade && \ | ||
9 | apt-get install -y -qq git wget build-essential zlib1g-dev libpcre3-dev git gcc g++ make && \ | ||
10 | rm -rf /var/lib/apt/lists/* | ||
11 | |||
12 | # Get Source Code | ||
13 | RUN \ | ||
14 | wget "http://nginx.org/download/nginx-1.11.3.tar.gz" && \ | ||
15 | wget "http://linux.stanford.edu/pub/exim/pcre/pcre-8.39.tar.gz" && \ | ||
16 | wget "https://www.openssl.org/source/openssl-1.0.2h.tar.gz" && \ | ||
17 | wget "http://zlib.net/zlib-1.2.8.tar.gz" && \ | ||
18 | git clone https://github.com/cuber/ngx_http_google_filter_module && \ | ||
19 | git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module && \ | ||
20 | tar xzf nginx-1.11.3.tar.gz && \ | ||
21 | tar xzf pcre-8.39.tar.gz && \ | ||
22 | tar xzf openssl-1.0.2h.tar.gz && \ | ||
23 | tar xzf zlib-1.2.8.tar.gz | ||
24 | |||
25 | ADD ./nginx.service /etc/init.d/nginx | ||
26 | ADD ./nginx.conf /etc/nginx/nginx.conf | ||
27 | |||
28 | # Install Nginx | ||
29 | RUN \ | ||
30 | cd nginx-1.11.3 && \ | ||
31 | ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --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-http_ssl_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_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-threads --with-stream --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_v2_module --with-ipv6 --with-pcre=../pcre-8.39 --with-openssl=../openssl-1.0.2h --with-zlib=../zlib-1.2.8 --add-module=../ngx_http_google_filter_module --add-module=../ngx_http_substitutions_filter_module && \ | ||
32 | make -j4 && \ | ||
33 | make install && \ | ||
34 | chmod +x /etc/init.d/nginx && \ | ||
35 | /usr/sbin/update-rc.d -f nginx defaults && \ | ||
36 | useradd --no-create-home nginx && \ | ||
37 | mkdir -p /var/cache/nginx | ||
38 | |||
39 | EXPOSE 80 | ||
40 | |||
41 | # Run Nginx | ||
42 | CMD service nginx start && tail -F /var/log/nginx/access.log | ||
@@ -0,0 +1,22 @@ | |||
1 | The MIT License (MIT) | ||
2 | |||
3 | Copyright (c) 2015 Jinwei Zhao | ||
4 | |||
5 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
6 | of this software and associated documentation files (the "Software"), to deal | ||
7 | in the Software without restriction, including without limitation the rights | ||
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
9 | copies of the Software, and to permit persons to whom the Software is | ||
10 | furnished to do so, subject to the following conditions: | ||
11 | |||
12 | The above copyright notice and this permission notice shall be included in all | ||
13 | copies or substantial portions of the Software. | ||
14 | |||
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
21 | SOFTWARE. | ||
22 | |||
diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000..60800d8 --- /dev/null +++ b/circle.yml | |||
@@ -0,0 +1,13 @@ | |||
1 | machine: | ||
2 | services: | ||
3 | - docker | ||
4 | |||
5 | dependencies: | ||
6 | override: | ||
7 | - docker info | ||
8 | - docker build -t nginx-proxy-google . | ||
9 | |||
10 | test: | ||
11 | override: | ||
12 | - docker run -d -p 8080:80 nginx-proxy-google; sleep 10 | ||
13 | |||
diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..2b5da16 --- /dev/null +++ b/nginx.conf | |||
@@ -0,0 +1,31 @@ | |||
1 | user nginx; | ||
2 | worker_processes 1; | ||
3 | |||
4 | events { | ||
5 | worker_connections 1024; | ||
6 | } | ||
7 | |||
8 | http { | ||
9 | include mime.types; | ||
10 | default_type application/octet-stream; | ||
11 | sendfile on; | ||
12 | keepalive_timeout 65; | ||
13 | |||
14 | server { | ||
15 | listen 80; | ||
16 | server_name localhost; | ||
17 | |||
18 | resolver 8.8.8.8; | ||
19 | |||
20 | location / { | ||
21 | google on; | ||
22 | google_scholar on; | ||
23 | google_language "en"; | ||
24 | } | ||
25 | |||
26 | error_page 500 502 503 504 /50x.html; | ||
27 | location = /50x.html { | ||
28 | root html; | ||
29 | } | ||
30 | } | ||
31 | } \ No newline at end of file | ||
diff --git a/nginx.service b/nginx.service new file mode 100644 index 0000000..7714aac --- /dev/null +++ b/nginx.service | |||
@@ -0,0 +1,62 @@ | |||
1 | #! /bin/sh | ||
2 | |||
3 | ### BEGIN INIT INFO | ||
4 | # Provides: nginx | ||
5 | # Required-Start: $all | ||
6 | # Required-Stop: $all | ||
7 | # Default-Start: 2 3 4 5 | ||
8 | # Default-Stop: 0 1 6 | ||
9 | # Short-Description: starts the nginx web server | ||
10 | # Description: starts nginx using start-stop-daemon | ||
11 | ### END INIT INFO | ||
12 | |||
13 | PATH=/opt/nginx/sbin:/sbin:/bin:/usr/sbin:/usr/bin | ||
14 | DAEMON=/usr/sbin/nginx | ||
15 | NAME=nginx | ||
16 | DESC=nginx | ||
17 | |||
18 | test -x $DAEMON || exit 0 | ||
19 | |||
20 | # Include nginx defaults if available | ||
21 | if [ -f /etc/default/nginx ] ; then | ||
22 | . /etc/default/nginx | ||
23 | fi | ||
24 | |||
25 | set -e | ||
26 | |||
27 | case "$1" in | ||
28 | start) | ||
29 | echo -n "Starting $DESC: " | ||
30 | start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \ | ||
31 | --exec $DAEMON -- $DAEMON_OPTS | ||
32 | echo "$NAME." | ||
33 | ;; | ||
34 | stop) | ||
35 | echo -n "Stopping $DESC: " | ||
36 | start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \ | ||
37 | --exec $DAEMON | ||
38 | echo "$NAME." | ||
39 | ;; | ||
40 | restart|force-reload) | ||
41 | echo -n "Restarting $DESC: " | ||
42 | start-stop-daemon --stop --quiet --pidfile \ | ||
43 | /var/run/$NAME.pid --exec $DAEMON | ||
44 | sleep 1 | ||
45 | start-stop-daemon --start --quiet --pidfile \ | ||
46 | /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS | ||
47 | echo "$NAME." | ||
48 | ;; | ||
49 | reload) | ||
50 | echo -n "Reloading $DESC configuration: " | ||
51 | start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/$NAME.pid \ | ||
52 | --exec $DAEMON | ||
53 | echo "$NAME." | ||
54 | ;; | ||
55 | *) | ||
56 | N=/etc/init.d/$NAME | ||
57 | echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 | ||
58 | exit 1 | ||
59 | ;; | ||
60 | esac | ||
61 | |||
62 | exit 0 \ No newline at end of file | ||