From 58a5701932a70f125a44d104aaa8bae3995b69f0 Mon Sep 17 00:00:00 2001
From: Navarr Barnier <me@navarr.me>
Date: Fri, 15 Nov 2024 10:54:20 -0500
Subject: [PATCH] Revert "feat(imgproxy): enable nginx to serve image filters"

---
 nginx/Dockerfile                          |  2 -
 nginx/etc/nginx/available.d/magento2.conf |  6 --
 nginx/etc/nginx/conf.d/default.conf       | 80 -----------------------
 3 files changed, 88 deletions(-)

diff --git a/nginx/Dockerfile b/nginx/Dockerfile
index 4ccb34b..1622e16 100644
--- a/nginx/Dockerfile
+++ b/nginx/Dockerfile
@@ -15,8 +15,6 @@ ENV NGINX_PUBLIC                  ''
 ENV NGINX_TEMPLATE                application.conf
 ENV XDEBUG_CONNECT_BACK_HOST      '""'
 
-RUN sed -i '1s/^/load_module \/etc\/nginx\/modules\/ngx_http_image_filter_module.so;\n\n/' /etc/nginx/nginx.conf
-
 COPY etc/nginx/fastcgi_params /etc/nginx/fastcgi_params.template
 COPY etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.template
 COPY etc/nginx/available.d/*.conf /etc/nginx/available.d/
diff --git a/nginx/etc/nginx/available.d/magento2.conf b/nginx/etc/nginx/available.d/magento2.conf
index ce1ae0a..b18e8de 100644
--- a/nginx/etc/nginx/available.d/magento2.conf
+++ b/nginx/etc/nginx/available.d/magento2.conf
@@ -94,12 +94,6 @@ location /static/ {
 }
 
 location /media/ {
-    location ~* ^/media/catalog/.* {
-        proxy_pass http://$image_resize_stream;
-        proxy_cache catalog_media;
-        proxy_cache_valid 200 24h;
-    }
-
     try_files $uri $uri/ /get.php$is_args$args;
 
     location ~ ^/media/theme_customization/.*\.xml {
diff --git a/nginx/etc/nginx/conf.d/default.conf b/nginx/etc/nginx/conf.d/default.conf
index 6b9d395..767be34 100644
--- a/nginx/etc/nginx/conf.d/default.conf
+++ b/nginx/etc/nginx/conf.d/default.conf
@@ -29,83 +29,3 @@ server {
     include /etc/nginx/available.d/${NGINX_TEMPLATE};
     include /etc/nginx/default.d/*.conf;
 }
-
-# create cache for resized images
-proxy_cache_path /tmp/nginx-catalog-media-cache/
-    levels=1:2
-    keys_zone=catalog_media:10m
-    inactive=24h
-    max_size=500m;
-
-# declare resize streams for legacy and new browsers
-map $http_accept $image_resize_stream {
-    default image_resize_legacy;
-    ~image/webp image_resize_webp;
-}
-
-upstream image_resize_webp {
-    server localhost:20001;
-}
-
-upstream image_resize_legacy {
-    server localhost:20002;
-}
-
-# server for modern browsers
-server {
-    server_name localhost;
-    listen 20001;
-
-    root ${NGINX_ROOT}${NGINX_PUBLIC};
-    set $MAGE_ROOT ${NGINX_ROOT};
-
-    location ~* ^/(?<path>media/catalog/.*)$ {
-        set $ext "";
-
-        # when request is made for image.jpg,
-        # check if image.jpg.webp is available.
-        if (-f $MAGE_ROOT/pub/$path.webp) {
-            set $ext .webp;
-        }
-
-        alias $MAGE_ROOT/pub/$path$ext;
-
-        set $width "-";
-        set $height "-";
-        if ($arg_width != '') {
-            set $width $arg_width;
-        }
-        if ($arg_height != '') {
-            set $height $arg_height;
-        }
-
-        image_filter resize $width $height;
-        image_filter_interlace on;
-        image_filter_jpeg_quality 75;
-        image_filter_webp_quality 75;
-    }
-}
-
-# server for legacy browsers
-server {
-    server_name localhost;
-    listen 20002;
-
-    root ${NGINX_ROOT}${NGINX_PUBLIC};
-
-    location / {
-        set $width "-";
-        set $height "-";
-        if ($arg_width != '') {
-            set $width $arg_width;
-        }
-        if ($arg_height != '') {
-            set $height $arg_height;
-        }
-
-        image_filter resize $width $height;
-        image_filter_interlace on;
-        image_filter_jpeg_quality 75;
-        image_filter_webp_quality 75;
-    }
-}
\ No newline at end of file