I was in the process of migrating a website to HTTPS. This migration involved using Cloudflare to handle the SSL certificate. The website has a blog on WordPress, a forum using phpBB and a wiki using MediaWiki. The blog and forum worked find but the wiki won’t load with the following error message.
[Wq9Als26rAsAAEtNvmwAAAAG] 2018-03-19 04:46:15: Fatal exception of type MWException
I did some searching and found a way to get a more verbose error message. In the LocalSettings.php, add “
$wgShowExceptionDetails = true;”. The verbose error message was:
[Wq82-s26rAoAAB1JWqgAAAAA] /wiki/Articles MWException from line 1176 of /nfs/c09/h05/mnt/000000/domains/domain.com/html/w/includes/WebRequest.php: WebRequest::getRawIP : Could not determine the remote IP address due to multiple values.
#0 /nfs/c09/h05/mnt/000000/domains/domain.com/html/w/includes/WebRequest.php(1203): WebRequest->getRawIP()
#1 /nfs/c09/h05/mnt/000000/domains/domain.com/html/w/includes/Setup.php(665): WebRequest->getIP()
#2 /nfs/c09/h05/mnt/000000/domains/domain.com/html/w/includes/WebStart.php(114): require_once(string)
#3 /nfs/c09/h05/mnt/000000/domains/domain.com/html/w/index.php(40): require(string)
I did some searching and found a reference in the the MediaWiki manual that said there are know issues. The article had many possible solutions but none that I could implement on my hosted web server. One patch even said it was obsolete in nearer versions of MediaWiki.
I did some more searching and found a Cloudflare support article that said the fix did work in later version of MediaWiki. The fix is:
UPDATE: For versions around 1.27.1
- Go to line 1232 in GlobalFunctions.php, change REMOTE_ADDR to HTTP_CF_CONNECTING_IP.
- Next, go to WebRequest.php, in lines 1151 to line 1159, change REMOTE_ADDR to HTTP_CF_CONNECTING_IP. (approximately three lines to change).
I made the changes, though the line numbers weren’t correct, and MediaWiki would now load using Cloudflare for HTTPS.