From eb289ab5f55f2b4ebd846f980fe7c35c707f855f Mon Sep 17 00:00:00 2001 From: Mike Bennett Date: Thu, 17 Aug 2023 20:43:04 +0100 Subject: [PATCH 1/2] Cantaloupe reverse proxy using IP --- nginx-vhost.conf | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/nginx-vhost.conf b/nginx-vhost.conf index 579eee4..379551a 100644 --- a/nginx-vhost.conf +++ b/nginx-vhost.conf @@ -11,22 +11,23 @@ server { alias /app/iiify/static; } - location ~ /iiif/image/([23])/(.*)$ { - rewrite ^ $request_uri; - rewrite ^/iiif/image/(2|3)/(.*)$ $2; - add_header 'Access-Control-Allow-Origin' '*' always; - add_header 'Access-Control-Allow-Methods' 'GET, HEAD, POST, PUT, PATCH, DELETE' always; - add_header 'Access-Control-Expose-Headers' '*' always; - return 302 https://services-ia-iiif-cantaloupe-experiment.dev.archive.org/iiif/$1/$2; - } + location ~ /image/iiif/([23])/(.*)$ { + rewrite ^ $request_uri; # Replace nginx $uri with the unescaped version + rewrite ^/image/iiif/(2|3)/(.*)$ /iiif/$1/$2 break; # capture and reformat the URI - location ~ /iiif/image/(.*)$ { - rewrite ^ $request_uri; - rewrite ^/iiif/image/(.*)$ $1; + # Settings to ensure Cantaloupe creates the right ids + # https://cantaloupe-project.github.io/manual/5.0/deployment.html#Reverse-Proxying + proxy_set_header X-Forwarded-Host iiif.archive.org; + proxy_set_header X-Forwarded-Path /image; + proxy_set_header X-Forwarded-For $remote_addr; + + # CORS add_header 'Access-Control-Allow-Origin' '*' always; add_header 'Access-Control-Allow-Methods' 'GET, HEAD, POST, PUT, PATCH, DELETE' always; add_header 'Access-Control-Expose-Headers' '*' always; - return 302 https://services-ia-iiif-cantaloupe-experiment.dev.archive.org/iiif/3/$1; - } + # Settings for IA load balancer + proxy_set_header Host cantaloupe.prod.archive.org; # So the LB knows what domain is being requested + proxy_pass https://207.241.239.241/ # IP of LB + } } From f6b761340f88e8381848d7486b42d1cc908fceeb Mon Sep 17 00:00:00 2001 From: Mike Bennett Date: Thu, 17 Aug 2023 21:01:37 +0100 Subject: [PATCH 2/2] Correct reverse_proxy URL --- nginx-vhost.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nginx-vhost.conf b/nginx-vhost.conf index 379551a..03f23c5 100644 --- a/nginx-vhost.conf +++ b/nginx-vhost.conf @@ -28,6 +28,6 @@ server { # Settings for IA load balancer proxy_set_header Host cantaloupe.prod.archive.org; # So the LB knows what domain is being requested - proxy_pass https://207.241.239.241/ # IP of LB + proxy_pass https://207.241.239.241/iiif/$1/$2; # IP of LB } }