From 1914fa7d5c5f52a4412c335bc8d203c0d98d3bde Mon Sep 17 00:00:00 2001 From: Sascha Nowak Date: Wed, 18 Dec 2024 10:27:14 +0100 Subject: [PATCH 1/2] feat: update nginx to 1.27.3 --- nginx/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nginx/Dockerfile b/nginx/Dockerfile index 0fa8883..79a44da 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:1 # Adding third-party modules to nginx official image # SEE https://github.com/nginxinc/docker-nginx/tree/master/modules -FROM nginx:1.27.2 AS builder +FROM nginx:1.27.3 AS builder ENV ENABLED_MODULES="headers-more subs-filter geoip2" SHELL ["/bin/bash", "-exo", "pipefail", "-c"] @@ -70,7 +70,7 @@ RUN apt-get update \ done \ && echo "BUILT_MODULES=\"$BUILT_MODULES\"" > /tmp/packages/modules.env -FROM nginx:1.27.2 AS nginx +FROM nginx:1.27.3 AS nginx ENV TZ="Europe/Berlin" RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone From 15086d48cbfd95a878e05dc4b5219cd8f56bb3ba Mon Sep 17 00:00:00 2001 From: Sascha Nowak Date: Wed, 18 Dec 2024 10:36:47 +0100 Subject: [PATCH 2/2] feat: add imgproxy config --- nginx/Dockerfile | 1 + nginx/etc/nginx/conf.d/imgproxy.conf | 7 +++++++ nginx/etc/nginx/includes/imgproxy | 7 +++++++ nginx/examples/imgproxy.conf.template | 8 ++++++++ 4 files changed, 23 insertions(+) create mode 100644 nginx/etc/nginx/conf.d/imgproxy.conf create mode 100644 nginx/etc/nginx/includes/imgproxy create mode 100644 nginx/examples/imgproxy.conf.template diff --git a/nginx/Dockerfile b/nginx/Dockerfile index 79a44da..7f482bd 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -89,6 +89,7 @@ COPY docker-entrypoint.d /docker-entrypoint.d # Test nginx config RUN nginx -t +VOLUME /var/cache/nginx HEALTHCHECK --interval=2s --timeout=20s --retries=10 CMD curl --silent --fail http://127.0.0.1:90/health || exit 1 diff --git a/nginx/etc/nginx/conf.d/imgproxy.conf b/nginx/etc/nginx/conf.d/imgproxy.conf new file mode 100644 index 0000000..b5f2724 --- /dev/null +++ b/nginx/etc/nginx/conf.d/imgproxy.conf @@ -0,0 +1,7 @@ +proxy_cache_path /var/cache/nginx/imgproxy levels=1:2 use_temp_path=off keys_zone=IMAGE_CACHE:32m max_size=10G min_free=32m inactive=7d; + +map $http_accept $imgproxy_extension { + default ''; + ~*webp '@webp'; + ~*avif '@avif'; +} \ No newline at end of file diff --git a/nginx/etc/nginx/includes/imgproxy b/nginx/etc/nginx/includes/imgproxy new file mode 100644 index 0000000..597a85e --- /dev/null +++ b/nginx/etc/nginx/includes/imgproxy @@ -0,0 +1,7 @@ +location /images/ { + add_header X-Proxy-Cache $upstream_cache_status; + proxy_cache IMAGE_CACHE; + proxy_cache_lock on; + proxy_cache_key "$host$request_uri $imgproxy_extension"; + proxy_pass http://imgproxy:8080/; +} diff --git a/nginx/examples/imgproxy.conf.template b/nginx/examples/imgproxy.conf.template new file mode 100644 index 0000000..0261cc6 --- /dev/null +++ b/nginx/examples/imgproxy.conf.template @@ -0,0 +1,8 @@ +server { + listen 80; + + server_name ${DOMAIN_ENV}; + + include includes/php; + include includes/imgproxy; +}