Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cantaloupe reverse proxy using resolver #3

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions nginx-vhost.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Set the resolver required by nginx for reverse-proxy lookups when using variables
resolver 9.9.9.9:53; # TODO: Change this to internal IA resolver

server {
listen 8080;
location / {
Expand All @@ -11,22 +14,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

# 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;

location ~ /iiif/image/(.*)$ {
rewrite ^ $request_uri;
rewrite ^/iiif/image/(.*)$ $1;
# 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;

# Reverse proxy with the variables captured above
proxy_pass https://cantaloupe.prod.archive.org/iiif/$1/$2;
}

}