Topic on Project:Support desk

MediaWiki Images Not Displaying When Switching to SSL

11
OutsideEdge94 (talkcontribs)
  • MediaWiki 1.36
  • Apache
  • PHP 7.3

I recently turned on SSL for a site running MediaWiki. When I did that, the thumbnail and file: page images are no longer displaying. Switching back to Non-SSL corrects the issue. The LocalSettings.php file has been changed to reflect the protocol-agnostic // URL in the $wgServer variable. All HTTP:// references in the database (via SRDB) have been modified to be HTTPS://

For example and to duplicate the issue:

  • https://www.spydiewiki.com/index.php?title=C07_Polices
  • Scroll to the bottom to see broken thumbnails.
  • If you click into the image, you see the content, but the image doesn't display here either
  • If you click the link for the image on this page, you get a really funky URL with the absolute path (definitely not what I want) in the URL and the site URL tacked on at the end.

I have tried repairing images, re-importing all the images, clearing cache, purging a page, and adding a new image to a page. With no success.

Has anyone seen this before or have any ideas about what might be causing it? It's gotta be pathing but, man, I can't seem to crack it.

Bawolff (talkcontribs)

What is $wgUploadPath set to? What are other file related config directives set to?

OutsideEdge94 (talkcontribs)

Bawolff, thanks for your reply. $wgUploadPath is set to "/images" and uploading images works fine. Also note that the whole system works as expected under a non-SSL environment. I want to say it's something with the rewrite rules under SSL but can't say for sure nor have I any clue as to how I would figure that out.

Seb35 (talkcontribs)
OutsideEdge94 (talkcontribs)

Seb35, thank you for your reply. Yes, I saw this strange URL as well. But as I said to Bawolff, all the URL references to images work as expected under a non-SSL environment. Do you have any thoughts on why SSL would cause the routing and rewriting of image references to go haywire like that?

Ciencia Al Poder (talkcontribs)

The problem is your $wgUploadPath variable seems misconfigured. It should be an URL or URL path, not filesystem path. Don't confuse it with $wgUploadDirectory!

OutsideEdge94 (talkcontribs)

Ciencia Al Poder, thank you for your reply. That var is set to "/images". Should that be a fully qualified URL? The script path is set to "" (null) and the default for $wgUploadPath default is "{$wgScriptPath}/images" so "/images/" seems like a valid setting.

Ciencia Al Poder (talkcontribs)

It's a valid setting, except that it wasn't valid when Seb35 and I checked, and your images were pointing to https://www.spydiewiki.com/var/www/vhosts/spydiewiki.comhttpdocs/images. Looks like it has been resolved now.

OutsideEdge94 (talkcontribs)
SweeBill (talkcontribs)

@OutsideEdge94

I was having an issue that may be related... I can't be sure...


check your .htaccess file on your server (for me it was under home/public_html). Make sure you have a rewrite condition for your url with an HTTPS and HTTP entries. Gere is an example of what it should look like:

RewriteCond %{HTTP_REFERER} !^https://example.com/.*$      [NC]

RewriteCond %{HTTP_REFERER} !^https://example.com$      [NC]

RewriteCond %{HTTP_REFERER} !^http://example.com/.*$      [NC]

RewriteCond %{HTTP_REFERER} !^http://example.com$       [NC]


I have created about 7 wiki's on my host's site and never had an issue. Just spent the last 5 hours troubleshooting a new wiki that I just created today. Finally I reached out to my host and they mentioned some issue with the .similar file. When I reviewed my .htaccess, I had entries for every single url except the new one. Once I added entries similar to above, images started working without any issues.

OutsideEdge94 (talkcontribs)

@SweeBill, that's great. Thanks for the insight. I'll take a look and give it a try. I really appreciate the help.

Reply to "MediaWiki Images Not Displaying When Switching to SSL"