Skip to content

Commit 248f7be

Browse files
committed
Merge branch 'hotfix/1.1.0'
* hotfix/1.1.0: Added 1.9-pagespeed tag, a pagespeed enabled Nginx
2 parents afb4faf + 102dffb commit 248f7be

File tree

4 files changed

+182
-0
lines changed

4 files changed

+182
-0
lines changed

1.9-pagespeed/Dockerfile

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
FROM debian:jessie
2+
3+
MAINTAINER Joeri Verdeyen <joeriv@yappa.be>
4+
5+
ENV PHP_FPM_SOCKET "php:9000"
6+
ENV DOCUMENT_ROOT /var/www/app/web
7+
ENV INDEX_FILE app_dev.php
8+
9+
ENV NPS_VERSION 1.9.32.10
10+
ENV NGINX_VERSION 1.9.6
11+
ENV OPENSSL_VERSION 1.0.2d
12+
ENV BUILDDIR /b
13+
14+
RUN echo deb http://http.debian.net/debian jessie-backports main >> /etc/apt/sources.list && \
15+
DEBIAN_FRONTEND=noninteractive apt-get update && \
16+
apt-get -y install -t jessie-backports wget unzip build-essential zlib1g-dev libpcre3 libpcre3-dev && \
17+
mkdir ${BUILDDIR} && cd ${BUILDDIR} && \
18+
wget https://github.com/pagespeed/ngx_pagespeed/archive/release-${NPS_VERSION}-beta.zip && \
19+
unzip release-${NPS_VERSION}-beta.zip && \
20+
cd ngx_pagespeed-release-${NPS_VERSION}-beta/ && \
21+
wget https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz && \
22+
tar -xzvf ${NPS_VERSION}.tar.gz && \
23+
cd ${BUILDDIR} && \
24+
wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz && \
25+
tar -xvzf nginx-${NGINX_VERSION}.tar.gz && \
26+
cd ${BUILDDIR} && \
27+
wget http://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz && \
28+
tar -xvzf openssl-${OPENSSL_VERSION}.tar.gz && \
29+
cd ${BUILDDIR}/nginx-${NGINX_VERSION} && \
30+
./configure \
31+
--add-module=${BUILDDIR}/ngx_pagespeed-release-${NPS_VERSION}-beta/ \
32+
--with-openssl=${BUILDDIR}/openssl-${OPENSSL_VERSION} \
33+
--prefix=/etc/nginx \
34+
--sbin-path=/usr/sbin/nginx \
35+
--conf-path=/etc/nginx/nginx.conf \
36+
--error-log-path=/var/log/nginx/error.log \
37+
--http-log-path=/var/log/nginx/access.log \
38+
--pid-path=/var/run/nginx.pid \
39+
--lock-path=/var/run/nginx.lock \
40+
--with-http_ssl_module \
41+
--with-http_realip_module \
42+
--with-http_addition_module \
43+
--with-http_sub_module \
44+
--with-http_dav_module \
45+
--with-http_flv_module \
46+
--with-http_mp4_module \
47+
--with-http_gunzip_module \
48+
--with-http_gzip_static_module \
49+
--with-http_random_index_module \
50+
--with-http_secure_link_module \
51+
--with-http_stub_status_module \
52+
--with-mail \
53+
--with-mail_ssl_module \
54+
--with-file-aio \
55+
--with-http_realip_module && \
56+
make && make install && \
57+
cd / && \
58+
rm -r ${BUILDDIR} && \
59+
apt-get purge -y --auto-remove wget build-essential unzip && \
60+
rm -rf /var/lib/apt/lists/* && \
61+
mkdir /ngx_pagespeed_cache && chmod -R 777 /ngx_pagespeed_cache && \
62+
echo Europe/Brussels > /etc/timezone && \
63+
dpkg-reconfigure --frontend noninteractive tzdata
64+
65+
COPY nginx.conf /etc/nginx/
66+
COPY default.conf /etc/nginx/sites-available/
67+
68+
RUN mkdir -p /etc/nginx/sites-enabled && \
69+
mkdir -p /etc/nginx/conf.d/ && \
70+
touch /etc/nginx/conf.d/upstream.conf && \
71+
ln -sf /etc/nginx/sites-available/default.conf /etc/nginx/sites-enabled/default && \
72+
usermod -u 1000 www-data && \
73+
ln -sf /dev/stderr /var/log/nginx/error.log
74+
75+
EXPOSE 80
76+
EXPOSE 443
77+
78+
COPY run.sh /run.sh
79+
80+
RUN chmod +x /run.sh
81+
82+
CMD ["/run.sh"]

1.9-pagespeed/default.conf

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
server {
2+
listen 80;
3+
4+
pagespeed on;
5+
6+
# Needs to exist and be writable by nginx. Use tmpfs for best performance.
7+
pagespeed FileCachePath /var/ngx_pagespeed_cache;
8+
9+
# Ensure requests for pagespeed optimized resources go to the pagespeed handler
10+
# and no extraneous headers get set.
11+
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
12+
add_header "" "";
13+
}
14+
location ~ "^/pagespeed_static/" { }
15+
location ~ "^/ngx_pagespeed_beacon$" { }
16+
17+
root DOCUMENT_ROOT;
18+
server_tokens on;
19+
20+
access_log /var/log/nginx/access.log;
21+
error_log /var/log/nginx/error.log;
22+
23+
index INDEX_FILE;
24+
25+
location / {
26+
try_files $uri $uri/ /INDEX_FILE$is_args$args;
27+
}
28+
29+
location ~ \.php$ {
30+
fastcgi_pass php-upstream;
31+
fastcgi_param SERVER_NAME $host;
32+
fastcgi_split_path_info ^(.+\.php)(/.*)$;
33+
34+
fastcgi_param QUERY_STRING $query_string;
35+
fastcgi_param REQUEST_METHOD $request_method;
36+
fastcgi_param CONTENT_TYPE $content_type;
37+
fastcgi_param CONTENT_LENGTH $content_length;
38+
39+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
40+
fastcgi_param PATH_INFO $fastcgi_script_name;
41+
42+
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
43+
fastcgi_param REQUEST_URI $request_uri;
44+
fastcgi_param DOCUMENT_URI $document_uri;
45+
fastcgi_param DOCUMENT_ROOT $document_root;
46+
fastcgi_param SERVER_PROTOCOL $server_protocol;
47+
48+
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
49+
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
50+
51+
fastcgi_param REMOTE_ADDR $remote_addr;
52+
fastcgi_param REMOTE_PORT $remote_port;
53+
fastcgi_param SERVER_ADDR $server_addr;
54+
fastcgi_param SERVER_PORT $server_port;
55+
fastcgi_param SERVER_NAME $server_name;
56+
57+
fastcgi_param HTTPS $https;
58+
59+
# PHP only, required if PHP was built with --enable-force-cgi-redirect
60+
fastcgi_param REDIRECT_STATUS 200;
61+
62+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
63+
fastcgi_param HTTPS off;
64+
fastcgi_read_timeout 120;
65+
}
66+
}

1.9-pagespeed/nginx.conf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
user www-data;
2+
worker_processes 4;
3+
pid /run/nginx.pid;
4+
5+
events {
6+
worker_connections 2048;
7+
multi_accept on;
8+
use epoll;
9+
}
10+
11+
http {
12+
server_tokens on;
13+
sendfile on;
14+
tcp_nopush on;
15+
tcp_nodelay on;
16+
keepalive_timeout 15;
17+
types_hash_max_size 2048;
18+
include /etc/nginx/mime.types;
19+
default_type application/octet-stream;
20+
access_log off;
21+
error_log off;
22+
gzip on;
23+
gzip_disable "msie6";
24+
include /etc/nginx/conf.d/*.conf;
25+
include /etc/nginx/sites-enabled/*;
26+
open_file_cache max=100;
27+
}
28+
29+
daemon off;

1.9-pagespeed/run.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
echo "upstream php-upstream { server $PHP_FPM_SOCKET; }" > /etc/nginx/conf.d/upstream.conf && \
3+
sed -i "s|DOCUMENT_ROOT|$DOCUMENT_ROOT|g" /etc/nginx/sites-available/default.conf && \
4+
sed -i "s|INDEX_FILE|$INDEX_FILE|g" /etc/nginx/sites-available/default.conf && \
5+
/usr/sbin/nginx

0 commit comments

Comments
 (0)