Skip to content

Commit 76a1d5e

Browse files
authored
Merge pull request #76 from kool-dev/ssl
enable https on nginx
2 parents 845daee + f5d402f commit 76a1d5e

31 files changed

Lines changed: 394 additions & 0 deletions

File tree

7.1-nginx-prod/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
1+
FROM debian AS cert
2+
3+
WORKDIR /kool/ssl
4+
5+
RUN apt-get update && \
6+
apt-get install -y openssl && \
7+
openssl genrsa -des3 -passout pass:x -out server.pass.key 2048 && \
8+
openssl rsa -passin pass:x -in server.pass.key -out _.localhost.key && \
9+
rm server.pass.key && \
10+
openssl req -new -key _.localhost.key -out server.csr \
11+
-subj "/C=XX/ST=XX/L=XX/O=Kool-Local/OU=Localhost/CN=*.localhost" && \
12+
openssl x509 -req -days 365 -in server.csr -signkey _.localhost.key -out _.localhost.crt && \
13+
openssl x509 -in _.localhost.crt -out _.localhost.pem
14+
115
FROM kooldev/php:7.1-prod
216

317
ENV PHP_FPM_LISTEN=/run/php-fpm.sock \
418
NGINX_LISTEN=80 \
19+
NGINX_HTTPS=false \
20+
NGINX_LISTEN_HTTPS=443 \
21+
NGINX_HTTPS_CERT=/kool/ssl/_.localhost.pem \
22+
NGINX_HTTPS_CERT_KEY=/kool/ssl/_.localhost.key \
523
NGINX_ROOT=/app/public \
624
NGINX_INDEX=index.php \
725
NGINX_CLIENT_MAX_BODY_SIZE=25M \
@@ -36,6 +54,7 @@ RUN curl -L https://github.com/ochinchina/supervisord/releases/download/v0.6.3/s
3654
COPY supervisor.conf /kool/supervisor.conf
3755
COPY default.tmpl /kool/default.tmpl
3856
COPY entrypoint /kool/entrypoint
57+
COPY --from=cert /kool/ssl /kool/ssl
3958
RUN chmod +x /kool/entrypoint
4059

4160
EXPOSE 80

7.1-nginx-prod/default.tmpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
server {
22
listen {{ .Env.NGINX_LISTEN }} default_server;
33
server_name _;
4+
{{ if isTrue .Env.NGINX_HTTPS }}
5+
listen {{ .Env.NGINX_LISTEN_HTTPS }} ssl http2;
6+
ssl_certificate {{ .Env.NGINX_HTTPS_CERT }};
7+
ssl_certificate_key {{ .Env.NGINX_HTTPS_CERT_KEY }};
8+
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
9+
ssl_ciphers HIGH:!aNULL:!MD5;
10+
{{ end }}
411
root {{ .Env.NGINX_ROOT }};
512
index {{ .Env.NGINX_INDEX }};
613
charset utf-8;

7.1-nginx/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
1+
FROM debian AS cert
2+
3+
WORKDIR /kool/ssl
4+
5+
RUN apt-get update && \
6+
apt-get install -y openssl && \
7+
openssl genrsa -des3 -passout pass:x -out server.pass.key 2048 && \
8+
openssl rsa -passin pass:x -in server.pass.key -out _.localhost.key && \
9+
rm server.pass.key && \
10+
openssl req -new -key _.localhost.key -out server.csr \
11+
-subj "/C=XX/ST=XX/L=XX/O=Kool-Local/OU=Localhost/CN=*.localhost" && \
12+
openssl x509 -req -days 365 -in server.csr -signkey _.localhost.key -out _.localhost.crt && \
13+
openssl x509 -in _.localhost.crt -out _.localhost.pem
14+
115
FROM kooldev/php:7.1
216

317
ENV PHP_FPM_LISTEN=/run/php-fpm.sock \
418
NGINX_LISTEN=80 \
19+
NGINX_HTTPS=false \
20+
NGINX_LISTEN_HTTPS=443 \
21+
NGINX_HTTPS_CERT=/kool/ssl/_.localhost.pem \
22+
NGINX_HTTPS_CERT_KEY=/kool/ssl/_.localhost.key \
523
NGINX_ROOT=/app/public \
624
NGINX_INDEX=index.php \
725
NGINX_CLIENT_MAX_BODY_SIZE=25M \
@@ -36,6 +54,7 @@ RUN curl -L https://github.com/ochinchina/supervisord/releases/download/v0.6.3/s
3654
COPY supervisor.conf /kool/supervisor.conf
3755
COPY default.tmpl /kool/default.tmpl
3856
COPY entrypoint /kool/entrypoint
57+
COPY --from=cert /kool/ssl /kool/ssl
3958
RUN chmod +x /kool/entrypoint
4059

4160
EXPOSE 80

7.1-nginx/default.tmpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
server {
22
listen {{ .Env.NGINX_LISTEN }} default_server;
33
server_name _;
4+
{{ if isTrue .Env.NGINX_HTTPS }}
5+
listen {{ .Env.NGINX_LISTEN_HTTPS }} ssl http2;
6+
ssl_certificate {{ .Env.NGINX_HTTPS_CERT }};
7+
ssl_certificate_key {{ .Env.NGINX_HTTPS_CERT_KEY }};
8+
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
9+
ssl_ciphers HIGH:!aNULL:!MD5;
10+
{{ end }}
411
root {{ .Env.NGINX_ROOT }};
512
index {{ .Env.NGINX_INDEX }};
613
charset utf-8;

7.2-nginx-prod/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
1+
FROM debian AS cert
2+
3+
WORKDIR /kool/ssl
4+
5+
RUN apt-get update && \
6+
apt-get install -y openssl && \
7+
openssl genrsa -des3 -passout pass:x -out server.pass.key 2048 && \
8+
openssl rsa -passin pass:x -in server.pass.key -out _.localhost.key && \
9+
rm server.pass.key && \
10+
openssl req -new -key _.localhost.key -out server.csr \
11+
-subj "/C=XX/ST=XX/L=XX/O=Kool-Local/OU=Localhost/CN=*.localhost" && \
12+
openssl x509 -req -days 365 -in server.csr -signkey _.localhost.key -out _.localhost.crt && \
13+
openssl x509 -in _.localhost.crt -out _.localhost.pem
14+
115
FROM kooldev/php:7.2-prod
216

317
ENV PHP_FPM_LISTEN=/run/php-fpm.sock \
418
NGINX_LISTEN=80 \
19+
NGINX_HTTPS=false \
20+
NGINX_LISTEN_HTTPS=443 \
21+
NGINX_HTTPS_CERT=/kool/ssl/_.localhost.pem \
22+
NGINX_HTTPS_CERT_KEY=/kool/ssl/_.localhost.key \
523
NGINX_ROOT=/app/public \
624
NGINX_INDEX=index.php \
725
NGINX_CLIENT_MAX_BODY_SIZE=25M \
@@ -36,6 +54,7 @@ RUN curl -L https://github.com/ochinchina/supervisord/releases/download/v0.6.3/s
3654
COPY supervisor.conf /kool/supervisor.conf
3755
COPY default.tmpl /kool/default.tmpl
3856
COPY entrypoint /kool/entrypoint
57+
COPY --from=cert /kool/ssl /kool/ssl
3958
RUN chmod +x /kool/entrypoint
4059

4160
EXPOSE 80

7.2-nginx-prod/default.tmpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
server {
22
listen {{ .Env.NGINX_LISTEN }} default_server;
33
server_name _;
4+
{{ if isTrue .Env.NGINX_HTTPS }}
5+
listen {{ .Env.NGINX_LISTEN_HTTPS }} ssl http2;
6+
ssl_certificate {{ .Env.NGINX_HTTPS_CERT }};
7+
ssl_certificate_key {{ .Env.NGINX_HTTPS_CERT_KEY }};
8+
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
9+
ssl_ciphers HIGH:!aNULL:!MD5;
10+
{{ end }}
411
root {{ .Env.NGINX_ROOT }};
512
index {{ .Env.NGINX_INDEX }};
613
charset utf-8;

7.2-nginx/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
1+
FROM debian AS cert
2+
3+
WORKDIR /kool/ssl
4+
5+
RUN apt-get update && \
6+
apt-get install -y openssl && \
7+
openssl genrsa -des3 -passout pass:x -out server.pass.key 2048 && \
8+
openssl rsa -passin pass:x -in server.pass.key -out _.localhost.key && \
9+
rm server.pass.key && \
10+
openssl req -new -key _.localhost.key -out server.csr \
11+
-subj "/C=XX/ST=XX/L=XX/O=Kool-Local/OU=Localhost/CN=*.localhost" && \
12+
openssl x509 -req -days 365 -in server.csr -signkey _.localhost.key -out _.localhost.crt && \
13+
openssl x509 -in _.localhost.crt -out _.localhost.pem
14+
115
FROM kooldev/php:7.2
216

317
ENV PHP_FPM_LISTEN=/run/php-fpm.sock \
418
NGINX_LISTEN=80 \
19+
NGINX_HTTPS=false \
20+
NGINX_LISTEN_HTTPS=443 \
21+
NGINX_HTTPS_CERT=/kool/ssl/_.localhost.pem \
22+
NGINX_HTTPS_CERT_KEY=/kool/ssl/_.localhost.key \
523
NGINX_ROOT=/app/public \
624
NGINX_INDEX=index.php \
725
NGINX_CLIENT_MAX_BODY_SIZE=25M \
@@ -36,6 +54,7 @@ RUN curl -L https://github.com/ochinchina/supervisord/releases/download/v0.6.3/s
3654
COPY supervisor.conf /kool/supervisor.conf
3755
COPY default.tmpl /kool/default.tmpl
3856
COPY entrypoint /kool/entrypoint
57+
COPY --from=cert /kool/ssl /kool/ssl
3958
RUN chmod +x /kool/entrypoint
4059

4160
EXPOSE 80

7.2-nginx/default.tmpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
server {
22
listen {{ .Env.NGINX_LISTEN }} default_server;
33
server_name _;
4+
{{ if isTrue .Env.NGINX_HTTPS }}
5+
listen {{ .Env.NGINX_LISTEN_HTTPS }} ssl http2;
6+
ssl_certificate {{ .Env.NGINX_HTTPS_CERT }};
7+
ssl_certificate_key {{ .Env.NGINX_HTTPS_CERT_KEY }};
8+
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
9+
ssl_ciphers HIGH:!aNULL:!MD5;
10+
{{ end }}
411
root {{ .Env.NGINX_ROOT }};
512
index {{ .Env.NGINX_INDEX }};
613
charset utf-8;

7.3-nginx-prod/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
1+
FROM debian AS cert
2+
3+
WORKDIR /kool/ssl
4+
5+
RUN apt-get update && \
6+
apt-get install -y openssl && \
7+
openssl genrsa -des3 -passout pass:x -out server.pass.key 2048 && \
8+
openssl rsa -passin pass:x -in server.pass.key -out _.localhost.key && \
9+
rm server.pass.key && \
10+
openssl req -new -key _.localhost.key -out server.csr \
11+
-subj "/C=XX/ST=XX/L=XX/O=Kool-Local/OU=Localhost/CN=*.localhost" && \
12+
openssl x509 -req -days 365 -in server.csr -signkey _.localhost.key -out _.localhost.crt && \
13+
openssl x509 -in _.localhost.crt -out _.localhost.pem
14+
115
FROM kooldev/php:7.3-prod
216

317
ENV PHP_FPM_LISTEN=/run/php-fpm.sock \
418
NGINX_LISTEN=80 \
19+
NGINX_HTTPS=false \
20+
NGINX_LISTEN_HTTPS=443 \
21+
NGINX_HTTPS_CERT=/kool/ssl/_.localhost.pem \
22+
NGINX_HTTPS_CERT_KEY=/kool/ssl/_.localhost.key \
523
NGINX_ROOT=/app/public \
624
NGINX_INDEX=index.php \
725
NGINX_CLIENT_MAX_BODY_SIZE=25M \
@@ -36,6 +54,7 @@ RUN curl -L https://github.com/ochinchina/supervisord/releases/download/v0.6.3/s
3654
COPY supervisor.conf /kool/supervisor.conf
3755
COPY default.tmpl /kool/default.tmpl
3856
COPY entrypoint /kool/entrypoint
57+
COPY --from=cert /kool/ssl /kool/ssl
3958
RUN chmod +x /kool/entrypoint
4059

4160
EXPOSE 80

7.3-nginx-prod/default.tmpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
server {
22
listen {{ .Env.NGINX_LISTEN }} default_server;
33
server_name _;
4+
{{ if isTrue .Env.NGINX_HTTPS }}
5+
listen {{ .Env.NGINX_LISTEN_HTTPS }} ssl http2;
6+
ssl_certificate {{ .Env.NGINX_HTTPS_CERT }};
7+
ssl_certificate_key {{ .Env.NGINX_HTTPS_CERT_KEY }};
8+
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
9+
ssl_ciphers HIGH:!aNULL:!MD5;
10+
{{ end }}
411
root {{ .Env.NGINX_ROOT }};
512
index {{ .Env.NGINX_INDEX }};
613
charset utf-8;

0 commit comments

Comments
 (0)