microsimulation / ijm-xml

XML files for the International Journal of Microsimulation
MIT License
0 stars 0 forks source link

System issue - cannot download PDFs, IIIF images #60

Closed Melissa37 closed 5 years ago

Melissa37 commented 5 years ago

Screenshot 2019-05-17 at 15 21 19

Click on PDF, then replaces currently page with:

Screenshot 2019-05-17 at 15 21 25

gnott commented 5 years ago

For me, PDFs loaded from the http://localhost:8080/ URL when running Docker locally. I think to fix this will be in the demo site with some configuration, if you are viewing a live demo site?

Melissa37 commented 5 years ago

Yes, I am using: https://demo--ijm.elifesciences.org/articles

giorgiosironi commented 5 years ago

Probably a similar issue to https://github.com/microsimulation/demo/pull/10 but let's solve that first and we'll check where this other hardcoded URL comes from (if it's not already covered).

gnott commented 5 years ago

Not entirely sure where the download configuration is from yet, I am following it to see.

The IJM content is similar to this line from the example branch https://github.com/microsimulation/demo/blob/example/api/data/articles/04395.json#L164

"pdf": "http://web:8082/04395/elife-04395-fig1-v2.tif"

I followed that pattern when generating IJM JSON files.

gnott commented 5 years ago

E.g.

https://github.com/microsimulation/demo/blob/master/api/data/articles/00001.json#L15

    "pdf": "http://web:8082/00001/ijm-00001.pdf",
giorgiosironi commented 5 years ago

Uhm http://demo--ijm.elifesciences.org/download/aHR0cDovL3dlYjo4MDgyLzAwMDUzL2lqbS0wMDA1My5wZGY=/ijm-00053.pdf?_hash=B5BO4Z7yWQiD1gIrsfInUViscVdKIJclwfKseD%2FFbKg%3D works whereas the original link http://localhost:8080/download/aHR0cDovL3dlYjo4MDgyLzAwMDUzL2lqbS0wMDA1My5wZGY=/ijm-00053.pdf?_hash=B5BO4Z7yWQiD1gIrsfInUViscVdKIJclwfKseD%2FFbKg%3D doesn't as localhost can't resolve. What should happen, I think, is that the hostname here resolves to the journal container and that proxies the request to the web:8082 that you have used. web:8082 only resolves from inside containers.

giorgiosironi commented 5 years ago

I think the problem is in the proxying that does not forward headers such as Host or X-Forwarded-Host.

giorgiosironi commented 5 years ago

Symfony ignores my attempts to set Host or X-Forwarded-Host with proxy_set_header.

giorgiosironi commented 5 years ago

As far as I can understand the settings in https://symfony.com/doc/3.4/console/request_context.html are only defaults so we can't go that route either.

giorgiosironi commented 5 years ago

Added Request::setTrustedProxies([$_SERVER['REMOTE_ADDR']], Request::HEADER_X_FORWARDED_ALL); which doesn't help either.

giorgiosironi commented 5 years ago

https://github.com/microsimulation/demo/pull/13 https://github.com/elifesciences/microsimulation-demo-formula/pull/4 seem to work for me, HTTPS pending as that can only be tested on AWS.

giorgiosironi commented 5 years ago

IIIF images have similar problems still, but the resolution needs to wait on the proxying fixes as they will need to be proxied as well to add HTTPS.

giorgiosironi commented 5 years ago

Finally fixed PDF links; images are a different matter.

gnott commented 5 years ago

Cool, thanks @giorgiosironi and others. It works for me on the demo site.

giorgiosironi commented 5 years ago

I suspect api_url_public is unused? We can allow public access without configuring it in journal.

giorgiosironi commented 5 years ago

Images fixed via more proxying.

thewilkybarkid commented 5 years ago

Think this can be closed now.