robcast / digilib

A versatile image viewing environment for the internet.
https://robcast.github.io/digilib/
GNU Lesser General Public License v3.0
18 stars 7 forks source link

(Behind a proxy,) iiif image API request for image id redirects to localhost:8080/.../info.json #37

Closed awagner-mainz closed 4 years ago

awagner-mainz commented 4 years ago

I have set up a test server docker image, with caddy forwarding 0.0.0.0:80/digilib to 0.0.0.0:8080/digilib, and hand-edited a manifest that digilib's manifester had produced.

The manifest is now at https://c110-182.cloud.gwdg.de/manifests/test!cc_ld_2.json and it specifies canvases/images/resources both as actual image in full resolution (in the @\id field) and as an iiif image API endpoint (in the service/@\id field). (The image API endpoint is the filename without "/info.json", e.g. "https://c110-182.cloud.gwdg.de/digilib/Scaler/IIIF/test!cc_ld_2!ASVCCLD_002_0001%2Bscala+cromatica".)

Now I seem to have the problem that mirador viewer calls upon the iiif image API rather than the hardcoded image URI to retrieve an image, but that digilib's scaler responds with a redirect to http://localhost:8080/digilib/Scaler/IIIF/test!cc_ld_2!ASVCCLD_002_0001%2Bscala+cromatica/info.json. Of course, mirador thinks this is a redirect to my home laptop's port 8080 and fails to find anything there. (For thumbnails it seems to work, strangely enough.)

I must admit that I have some difficulty in understanding what happens in terms of requests and redirects and whether this is something that has to be fixed in my proxy setup or on digilib's side... I would be thankful for any pointers.

PS. You can see the problem in this mirador instance

robcast commented 4 years ago

Congratulations! I think you have found a bug again :-)

I have not looked at the code but I think the logic that creates the correct URLs using iiif-image-base-url (that @hertzhaft wanted to write documentation for ;-) is not applied for the redirect to /info.json...

I'll check that.

hertzhaft commented 4 years ago

Hi Andreas,

I think there are perhaps two issues involved:

One is that you need to set a base url for IIIF responses in digilib's configuration (WEB-INF/digilib-config.xml), for example:

<parameter

name="iiif-image-base-url"

value="https://c110-182.cloud.gwdg.de/digilib/Scaler/IIIF"/>

<parameter

name="webapp-base-url"

value="http://https://c110-182.cloud.gwdg.de"/>

The first one is for images, the second one for manifests. Playing around with these will help you set the right values.

Unfortunately, these config params are not yet documented. I volunteered but haven't got around to do it ...

The other issue may be your proxy. In Apache you would set ProxyPreserveHost = On to keep the "Host" header of the forwarded request. I don't really know if Mirador is looking at it when resolving addresses.

HTH, good luck!

Martin

Andreas Wagner wrote on 26.05.20 16:24:

I have set up a test server docker image, with caddy forwarding 0.0.0.0:80/digilib to 0.0.0.0:8080/digilib, and hand-edited a manifest that digilib's manifester had produced.

The manifest is now at https://c110-182.cloud.gwdg.de/manifests/test!cc_ld_2.json and it specifies canvases/images/resources both as actual image in full resolution (in the @\id field) and as an iiif image API endpoint (in the service/@\id field). (The image API endpoint is the filename without "/info.json", e.g. "https://c110-182.cloud.gwdg.de/digilib/Scaler/IIIF/test!cc_ld_2!ASVCCLD_002_0001%2Bscala+cromatica".)

Now I seem to have the problem that mirador viewer calls upon the iiif image API rather than the hardcoded image URI to retrieve an image, but that digilib's scaler responds with a redirect to http://localhost:8080/digilib/Scaler/IIIF/test!cc_ld_2!ASVCCLD_002_0001%2Bscala+cromatica/info.json. Of course, mirador thinks this is a redirect to my home laptop's port 8080 and fails to find anything there. (For thumbnails it seems to work, strangely enough.)

I must admit that I have some difficulty in understanding what happens in terms of requests and redirects and whether this is something that has to be fixed in my proxy setup or on digilib's side... I would be thankful for any pointers.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/robcast/digilib/issues/37, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHJAMVKTSN7YGSODUUCCLLRTPGLLANCNFSM4NKLMNKQ.

robcast commented 4 years ago

@awagner-mainz seems to have at least the problem of the missing Host header that @hertzhaft mentioned and has not set iiif-image-base-url because the @id in https://c110-182.cloud.gwdg.de/digilib/Scaler/IIIF/test!cc_ld_2!ASVCCLD_002_0001%2Bscala+cromatica/info.json also shows localhost.

But even if he had set iiif-image-base-url (without the Host header) it would not have helped because the redirect in https://github.com/robcast/digilib/blob/8e2a54f430535d0a2a30554c3d8f60e734ed811a/servlet3/src/main/java/digilib/servlet/Scaler.java#L265 does not use the config parameter :-)

awagner-mainz commented 4 years ago

Yay! That was a quick fix! I added the two parameters to my config, restarted, and now it seems to work - without any additional changes (as can be evidenced in the mirador instance mentioned in the OP). That's not to say that other things can not be improved as well, of course ;-)