From 02381b535014b3fde2b3175eed357b743959ddde Mon Sep 17 00:00:00 2001 From: Polmonite Date: Fri, 13 Dec 2019 14:13:54 +0100 Subject: [PATCH 1/3] Imgix rule was too generic --- README.md | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 8a27fb4..31a3409 100644 --- a/README.md +++ b/README.md @@ -103,25 +103,27 @@ server { # ... server_name ~^(www\.)?(?.+)$; - location ~ ^/.*/uploads/(.+)\-([0-9]+)x([0-9]+)\.([^\.]+)$ { - rewrite ^/.*/uploads/(.+)\-([0-9]+)x([0-9]+)\.([^\.]+)$ /uploads/$1.$4?$args&w=$2&h=$3; - } - - location ~ ^/.*/uploads/(.+)\-([0-9]+)\.([^\.]+)$ { - rewrite ^/.*/uploads/(.+)\-([0-9]+)\.([^\.]+)$ /uploads/$1.$3?$args&w=$2; - } - - location ~ ^/.*/uploads/(.+)$ { - rewrite ^/.*/uploads/(.+)$ /uploads/$1; - } - - location ~ ^/uploads/.*$ { - try_files $uri @imgix; - } - - location @imgix { - proxy_pass https://$domain.imgix.net; - } + set $uploads_uri $uri; + location ~ ^/.*/uploads/(.+)$ { + rewrite ^/.*/uploads/(.+)$ /uploads/$1; + set $uploads_uri $uri; + } + + location ~ ^/uploads/(.+)\-([0-9]+)x([0-9]+)\.([^\.]+)$ { + rewrite ^/uploads/(.+)\-([0-9]+)x([0-9]+)\.([^\.]+)$ /uploads/$1.$4?$args&w=$2&h=$3; + } + + location ~ ^/uploads/(.+)\-([0-9]+)\.([^\.]+)$ { + rewrite ^/uploads/(.+)\-([0-9]+)\.([^\.]+)$ /uploads/$1.$3?$args&w=$2; + } + + location ~ ^/uploads/.*$ { + try_files $uploads_uri $uri @imgix; + } + + location @imgix { + proxy_pass https://aircs3.imgix.net; + } # ... # WordPress configuration From 12e75cc71d7d4b0646f817ae8a9e79555a6738b9 Mon Sep 17 00:00:00 2001 From: Polmonite Date: Fri, 13 Dec 2019 14:14:41 +0100 Subject: [PATCH 2/3] Removed tabs --- README.md | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 31a3409..f46d83c 100644 --- a/README.md +++ b/README.md @@ -103,27 +103,27 @@ server { # ... server_name ~^(www\.)?(?.+)$; - set $uploads_uri $uri; - location ~ ^/.*/uploads/(.+)$ { - rewrite ^/.*/uploads/(.+)$ /uploads/$1; - set $uploads_uri $uri; - } - - location ~ ^/uploads/(.+)\-([0-9]+)x([0-9]+)\.([^\.]+)$ { - rewrite ^/uploads/(.+)\-([0-9]+)x([0-9]+)\.([^\.]+)$ /uploads/$1.$4?$args&w=$2&h=$3; - } - - location ~ ^/uploads/(.+)\-([0-9]+)\.([^\.]+)$ { - rewrite ^/uploads/(.+)\-([0-9]+)\.([^\.]+)$ /uploads/$1.$3?$args&w=$2; - } - - location ~ ^/uploads/.*$ { - try_files $uploads_uri $uri @imgix; - } - - location @imgix { - proxy_pass https://aircs3.imgix.net; - } + set $uploads_uri $uri; + location ~ ^/.*/uploads/(.+)$ { + rewrite ^/.*/uploads/(.+)$ /uploads/$1; + set $uploads_uri $uri; + } + + location ~ ^/uploads/(.+)\-([0-9]+)x([0-9]+)\.([^\.]+)$ { + rewrite ^/uploads/(.+)\-([0-9]+)x([0-9]+)\.([^\.]+)$ /uploads/$1.$4?$args&w=$2&h=$3; + } + + location ~ ^/uploads/(.+)\-([0-9]+)\.([^\.]+)$ { + rewrite ^/uploads/(.+)\-([0-9]+)\.([^\.]+)$ /uploads/$1.$3?$args&w=$2; + } + + location ~ ^/uploads/.*$ { + try_files $uploads_uri $uri @imgix; + } + + location @imgix { + proxy_pass https://aircs3.imgix.net; + } # ... # WordPress configuration From b87b6680a3905dc0dfbb3dd84c7f9c972d67cb22 Mon Sep 17 00:00:00 2001 From: Ani Date: Fri, 10 Apr 2020 23:29:20 +0200 Subject: [PATCH 3/3] [+] Fix $domain --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f46d83c..1f11ecd 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,13 @@ The WordPress generated thumbnails (resized images) will be moved to S3 automati > This approach isn't recommended because it creates unnecessary copies of the same file and it adds load to the server. Use a service to resize photos on the fly instead and turn off image resizing on WordPress. And then simply proxy the images from Nginx like below. +If you use the configuration below. The web server will check for the files through the URL and in the end will forward to imgix.com automatically constructing the url of the imgix bucket as the following: + +-> $domain.imgix.net +-> if your website domain is `caffeina.com` then your imgix bucket would be `caffeina.com.imgix.net` + +Remember that the configuration accepts any domain name but the imgix bucket will only work with one so this is not ideal. + ```lua server { # ... @@ -122,7 +129,7 @@ server { } location @imgix { - proxy_pass https://aircs3.imgix.net; + proxy_pass https://$domain.imgix.net; } # ...