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; +}