Topic on Extension talk:MultimediaViewer

Summary by Tgr (WMF)

A web server configuration issue.

Sophivorus (talkcontribs)

I installed MediaViewer (and CommonsMetadata) in the wiki at http://www.auslandssemester-bali.de, and it works fine for the most part, but when I omit the 'www', I get the following error:

Error: Could not load thumbnail data. could not load image from http://www.auslandssemester-bali.de/images/thumb/a/a3/Apartment-Nala-Seminyak-Bali-14.jpg/320px-Apartment-Nala-Seminyak-Bali-14.jpg

Also the console throws this error:

XMLHttpRequest cannot load http://www.auslandssemester-bali.de/images/thumb/a/a3/Apartment-Nala-Seminyak-Bali-14.jpg/320px-Apartment-Nala-Seminyak-Bali-14.jpg. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://auslandssemester-bali.de' is therefore not allowed access.

My images/.htaccess file has the required line:

Header add Access-Control-Allow-Origin "*"

I tried setting and modifying the relevant headers at runtime in all the entry points, but no luck. I also tried adding the following to LocalSettings.php:

$wgCrossSiteAJAXdomains = array( 'auslandssemester-bali.de' );

Yet nothing. Maybe it's something in my server setup, but it may also be a MediaViewer bug. Anyone knows what may be wrong or how to fix it? Thanks!

Tgr (WMF) (talkcontribs)

That .htaccess rule does not seem to be working:

$ curl -vso /dev/null 'http://www.auslandssemester-bali.de/images/thumb/a/a3/Apartment-Nala-Seminyak-Bali-14.jpg/320px-Apartment-Nala-Seminyak-Bali-14.jpg'
* Hostname was NOT found in DNS cache
*   Trying 216.70.97.136...
* Connected to www.auslandssemester-bali.de (216.70.97.136) port 80 (#0)
> GET /images/thumb/a/a3/Apartment-Nala-Seminyak-Bali-14.jpg/320px-Apartment-Nala-Seminyak-Bali-14.jpg HTTP/1.1
> User-Agent: curl/7.35.0
> Host: www.auslandssemester-bali.de
> Accept: */*
> 
< HTTP/1.1 200 OK
* Server nginx is not blacklisted
< Server: nginx
< Date: Wed, 22 Apr 2015 18:27:23 GMT
< Content-Type: image/jpeg
< Content-Length: 48804
< Last-Modified: Wed, 22 Apr 2015 16:51:43 GMT
< Connection: keep-alive
< ETag: "5537d19f-bea4"
< X-Powered-By: PleskLin
< Accept-Ranges: bytes
< 
{ [data not shown]
* Connection #0 to host www.auslandssemester-bali.de left intact

Also, the server claims to be nginx, not apache.

TheDJ (talkcontribs)
< HTTP/1.1 200 OK
< Server: nginx
< Date: Wed, 22 Apr 2015 18:35:32 GMT
< Content-Type: image/jpeg
< Content-Length: 35123
< Last-Modified: Thu, 04 Sep 2014 10:21:33 GMT
< Connection: keep-alive
< ETag: "54083d2d-8933"
< X-Powered-By: PleskLin
< Accept-Ranges: bytes

So as you can see your image does not have the header. But it does need one. So whatever you need to do to convince your webserver to add that header to those requests... You probably want to read: http://wiki.nginx.org/LikeApache-htaccess however

$wgCrossSiteAJAXdomains is only relevant for api requests.

Sophivorus (talkcontribs)

Thanks both for your help. Today I woke up smart and realised that the best solution for my case is to force the URL to always have the 'www', by adding the following lines to my .htaccess file:

RewriteCond %{HTTP_HOST} ^auslandssemester-bali.de$
RewriteRule ^(.*) http://www.auslandssemester-bali.de/$1 [R=301]

Problem fixed!