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