Skip to content

Commit e95f63a

Browse files
committed
add h5bp nginx configuration
1 parent d0b9f9c commit e95f63a

4 files changed

Lines changed: 26 additions & 3 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
Minimal PHP Docker image focused on Laravel applications. It's use is intended for [kool.dev](https://github.com/kool-dev/kool), but can fit in any other PHP use-case.
66

7+
The images with Nginx include [`h5bp/server-configs-nginx`](https://github.com/h5bp/server-configs-nginx) with a hand picked set of configuration active by default. So if you want to change or add a new server configuration you can `include h5bp/...` as you see fit.
8+
79
### Usage
810

911
Simplest example:

template/Dockerfile-nginx.blade.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
RUN curl -L https://github.com/ochinchina/supervisord/releases/download/v0.6.3/supervisord_static_0.6.3_linux_amd64 -o /usr/local/bin/supervisord \
1414
&& chmod +x /usr/local/bin/supervisord \
1515
&& apk add --no-cache nginx \
16-
&& sed -i "s|^user .*|user\ kool kool;|g" /etc/nginx/nginx.conf \
1716
@if (version_compare($version, '7.2', '>='))
1817
&& chown -R kool:kool /var/lib/nginx \
1918
&& chmod 770 /var/lib/nginx/tmp \
@@ -22,7 +21,18 @@
2221
&& chmod 770 /var/tmp/nginx \
2322
@endif
2423
&& ln -sf /dev/stdout /var/log/nginx/access.log \
25-
&& ln -sf /dev/stderr /var/log/nginx/error.log
24+
&& ln -sf /dev/stderr /var/log/nginx/error.log \
25+
# add h5bp/server-configs-nginx
26+
&& mkdir /etc/nginx/h5bp \
27+
&& cd /etc/nginx/h5bp \
28+
&& wget https://github.com/h5bp/server-configs-nginx/archive/refs/tags/3.3.0.tar.gz -O h5bp.tgz \
29+
&& tar xzvf h5bp.tgz \
30+
&& rm -f h5bp.tgz \
31+
&& mv server-configs-nginx-*/h5bp/* . \
32+
&& mv server-configs-nginx-*/nginx.conf /etc/nginx/nginx.conf \
33+
&& sed -i "s|^user .*|user\ kool kool;|g" /etc/nginx/nginx.conf \
34+
&& mv server-configs-nginx-*/mime.types /etc/nginx/mime.types \
35+
&& rm -rf server-configs-nginx-*
2636

2737
COPY supervisor.conf /kool/supervisor.conf
2838
COPY default.tmpl /kool/default.tmpl

template/default-tmpl.blade.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,15 @@
3030
location ~ /\.ht {
3131
deny all;
3232
}
33+
34+
# basic H5BP suggestions
35+
include h5bp/internet_explorer/x-ua-compatible.conf;
36+
include h5bp/security/referrer-policy.conf;
37+
include h5bp/security/x-content-type-options.conf;
38+
include h5bp/security/x-frame-options.conf;
39+
include h5bp/security/x-xss-protection.conf;
40+
41+
# performance enhancements (mostly for caching static data)
42+
include h5bp/web_performance/cache-file-descriptors.conf;
43+
include h5bp/web_performance/pre-compressed_content_gzip.conf;
3344
}

template/supervisor-conf.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[program:nginx]
22
depends_on = php-fpm
3-
command = nginx -g "pid /run/nginx.pid; daemon off;"
3+
command = nginx -g "daemon off;"
44
stopasgroup = true
55
stderr_logfile = /dev/stderr
66
stdout_logfile = /dev/stdout

0 commit comments

Comments
 (0)