Endless redirects (302) using direct links to shared images

Hi,

I get endless redirects when I for instance paste a direct link to an image on a bulletin board inside an IMG-tag.

Using NextCloud 9.0.53, Apache 2.4.23 and FreeBSD. And I actually also have a reverse proxy (nginx) in front of the Apache web server. I’m also using SSL.

Tried this:

  • Reinstalling multiple times (did not help).
  • Removing .htaccess file (did not help).
  • Fiddling with config/config.php.
  • Lots of googling.

Though somehow I think that the problem has to do with cookies. Because I also tried CURL’ing without Cookie-headers and it worked fine. Then when I tried with a Cookie-header, I get endless redirects.

Workaround seems to be a “return”-statement as the first line of the ‘performSameSiteCookieProtection’-function in lib/base.php.

Then it works fine.

But that’s not really a solution to the problem and maybe I need that cookie protection?

Anyone know what’s going on?

Downloading via such a shared link is fine, by the way. But put it in an image tag and it gets this redirect loop (Chrome then errors out and image is not displayed).

Any help’s appreciated!

^^^^^ @lukasreschke


Now I’ve tried without the reverse proxy, directly to Apache 2.4.23 and without SSL. Still the same behaviour. Cannot share an image inside an IMG-tag because of a redirect loop.

Update:
Also tried latest nginx-version (again without reverse proxy and without SSL). Same behaviour.

did you ever find the solution to this problem? I am having the same issue.

Well I went back to ownCloud. It is possible in nextCloud but you would have to ‘hack’ it:

It seems to be a security measure but with the effect of not being able to share images directly via forums or such.

A fix has been merged into 13.0.4: https://github.com/nextcloud/server/pull/6599
You should use the share link either without /download (which caused a few issues with our embedded pictures) or us the new feature and append /preview to your share links.