Hello list,
for some reason I'm no longer able to use the upload function on my little Mediawiki installation. I haven't uploaded things a while, and recently updated to 1.43.1, and everything else appears to work quite well, except uploads. So, I navigate to Special:Upload and in the Apache web server log I can see (shortened, w/o IP adresses and user information):
"GET /wiki/Special:Upload HTTP/2.0" 200 5795 "-" "Mozilla...
Great, HTTP/200 looks good, and the "Upload file" page is being displayed, and I click on "choose file" and select a .gif and the .gif is displayed now displayed as a little preview in the "Source file" part of the Upload page. But then I hit the "Upload file" at the bottom of the page and get a "Not Found" message in my browser window. And the same Apache web server log now has:
"POST /wiki/Special:Upload HTTP/2.0" 404 291 "https://foo.example.org/wiki/Special:Upload" "Mozilla...
So, GET works just fine, but POST produces a HTTP/404?
I've disabled mod_security, disabled all CSP and X-XSS-Protection etc. headers too, but I'm at a loss on how to debug this further.
In my virtual host configuration of the Apache web server, the following is included:
RewriteRule ^/wiki/(.+)?$ /mediawiki/index.php [L]
This worked quite well over the years, and I *was* able to upload stuff before, and with that configuration too.
Attached below is my (shortened) LocalSettings.php (w/o some database secrets and names).
Has anybody seen something like this before, and maybe even remembers where to look to debug this?
Thank you, Christian.
===== LocalSettings.php $wgSitename = "foo"; $wgScriptPath = "/mediawiki"; # real path $wgArticlePath = "/wiki/$1"; # virtual path $wgUsePathInfo = true; # ? $wgServer = "https://foo.example.org"; $wgEnotifUserTalk = true; # UPO $wgEnotifWatchlist = true; # UPO $wgEmailAuthentication = true; $wgDBtype = "mysql"; $wgDBserver = "127.0.0.1"; $wgDBname = "foo"; $wgDBuser = "foo"; $wgDBpassword = "xxxx"; $wgDBprefix = ""; $wgMainCacheType = CACHE_ACCEL; $wgCachePages = true; $wgParserCacheExpireTime = 604800; $wgUseFileCache = true; $wgEnableSidebarCache = true; $wgShowIPinHeader = false; $wgEnableUploads = true; $wgUseImageMagick = true; $wgImageMagickConvertCommand = "/usr/bin/convert"; $wgShellLocale = "en_US.utf8"; $wgCacheDirectory = "$IP/cache"; $wgFileCacheDirectory = "$wgCacheDirectory/html"; $wgLanguageCode = "en"; $wgSecretKey = "xxxx"; $wgUpgradeKey = "xxx"; $wgDefaultSkin = "Vector"; $wgDiff3 = "/usr/bin/diff3"; $wgGroupPermissions['*']['read'] = true; $wgGroupPermissions['*']['edit'] = false; $wgGroupPermissions['*']['createaccount'] = false; $wgNoFollowLinks = false; $wgNamespacesWithSubpages[NS_MAIN] = true; $wgAllowExternalImages = true; $wgAllowCopyUploads = true; $wgCopyUploadsFromSpecialUpload = true; $wgFileExtensions = array_merge($wgFileExtensions, array( 'pdf', 'txt', 'gz', 'bz2', 'deb', 'zip', 'svg', 'diff', 'json' )); $wgVerifyMimeType = false; $wgDisableUploadScriptChecks = true; $wgExtraNamespaces = array( $wgNamespacesWithSubpages[NS_FOO] = true; $wgNamespacesWithSubpages[NS_FOO] = true; $wgShowExceptionDetails = true; $wgDevelopmentWarnings = true; $wgSitemapNamespaces = array( 0, 4, 12 ); $wgAllowTitlesInSVG = true; $wgSVGConverter = 'ImageMagick'; wfLoadSkin('Vector'); wfLoadSkin('MinervaNeue'); wfLoadSkin('Timeless');
If i were to guess, probably something wrong with apache config (e.g. for some reason the rewrite rule is ignored on POST). Check your apache error log.
-- Brian
On Sunday, 4 May 2025, Christian Kujau lists@nerdbynature.de wrote:
Hello list,
for some reason I'm no longer able to use the upload function on my little Mediawiki installation. I haven't uploaded things a while, and recently updated to 1.43.1, and everything else appears to work quite well, except uploads. So, I navigate to Special:Upload and in the Apache web server log I can see (shortened, w/o IP adresses and user information):
"GET /wiki/Special:Upload HTTP/2.0" 200 5795 "-" "Mozilla...
Great, HTTP/200 looks good, and the "Upload file" page is being displayed, and I click on "choose file" and select a .gif and the .gif is displayed now displayed as a little preview in the "Source file" part of the Upload page. But then I hit the "Upload file" at the bottom of the page and get a "Not Found" message in my browser window. And the same Apache web server log now has:
"POST /wiki/Special:Upload HTTP/2.0" 404 291 " https://foo.example.org/wiki/Special:Upload" "Mozilla...
So, GET works just fine, but POST produces a HTTP/404?
I've disabled mod_security, disabled all CSP and X-XSS-Protection etc. headers too, but I'm at a loss on how to debug this further.
In my virtual host configuration of the Apache web server, the following is included:
RewriteRule ^/wiki/(.+)?$ /mediawiki/index.php [L]
This worked quite well over the years, and I *was* able to upload stuff before, and with that configuration too.
Attached below is my (shortened) LocalSettings.php (w/o some database secrets and names).
Has anybody seen something like this before, and maybe even remembers where to look to debug this?
Thank you, Christian.
===== LocalSettings.php $wgSitename = "foo"; $wgScriptPath = "/mediawiki"; # real path $wgArticlePath = "/wiki/$1"; # virtual path $wgUsePathInfo = true; # ? $wgServer = "https://foo.example.org"; $wgEnotifUserTalk = true; # UPO $wgEnotifWatchlist = true; # UPO $wgEmailAuthentication = true; $wgDBtype = "mysql"; $wgDBserver = "127.0.0.1"; $wgDBname = "foo"; $wgDBuser = "foo"; $wgDBpassword = "xxxx"; $wgDBprefix = ""; $wgMainCacheType = CACHE_ACCEL; $wgCachePages = true; $wgParserCacheExpireTime = 604800; $wgUseFileCache = true; $wgEnableSidebarCache = true; $wgShowIPinHeader = false; $wgEnableUploads = true; $wgUseImageMagick = true; $wgImageMagickConvertCommand = "/usr/bin/convert"; $wgShellLocale = "en_US.utf8"; $wgCacheDirectory = "$IP/cache"; $wgFileCacheDirectory = "$wgCacheDirectory/html"; $wgLanguageCode = "en"; $wgSecretKey = "xxxx"; $wgUpgradeKey = "xxx"; $wgDefaultSkin = "Vector"; $wgDiff3 = "/usr/bin/diff3"; $wgGroupPermissions['*']['read'] = true; $wgGroupPermissions['*']['edit'] = false; $wgGroupPermissions['*']['createaccount'] = false; $wgNoFollowLinks = false; $wgNamespacesWithSubpages[NS_MAIN] = true; $wgAllowExternalImages = true; $wgAllowCopyUploads = true; $wgCopyUploadsFromSpecialUpload = true; $wgFileExtensions = array_merge($wgFileExtensions, array( 'pdf', 'txt', 'gz', 'bz2', 'deb', 'zip', 'svg', 'diff', 'json' )); $wgVerifyMimeType = false; $wgDisableUploadScriptChecks = true; $wgExtraNamespaces = array( $wgNamespacesWithSubpages[NS_FOO] = true; $wgNamespacesWithSubpages[NS_FOO] = true; $wgShowExceptionDetails = true; $wgDevelopmentWarnings = true; $wgSitemapNamespaces = array( 0, 4, 12 ); $wgAllowTitlesInSVG = true; $wgSVGConverter = 'ImageMagick'; wfLoadSkin('Vector'); wfLoadSkin('MinervaNeue'); wfLoadSkin('Timeless');
-- BOFH excuse #308:
CD-ROM server needs recalibration _______________________________________________ MediaWiki-l mailing list -- mediawiki-l@lists.wikimedia.org To unsubscribe send an email to mediawiki-l-leave@lists.wikimedia.org https://lists.wikimedia.org/postorius/lists/mediawiki-l. lists.wikimedia.org/
On Sun, 4 May 2025, Brian Wolff wrote:
If i were to guess, probably something wrong with apache config (e.g. for some reason the rewrite rule is ignored on POST). Check your apache error log.
Yes, it was some Rewrite snafu after all. Installed a fresh Mediawiki on the same machine with a different path, and as soon as I enabled the ShortURL hacks the same thing happened.
So, I re-read the documentation for Apache[0] again and now have:
Alias /wiki /var/www/mediawiki/index.php RewriteRule ^/*$ %{DOCUMENT_ROOT}/mediawiki/index.php [L]
And, in LocalSettings.php:
$wgScriptPath = "/mediawiki"; $wgArticlePath = "/wiki/$1"; $wgUsePathInfo = true;
For some reason I never had that "Alias" directive in my Apache configuration before, I don't know how this even worked before. But with all that uploads are working again. \o/
Thanks for responding!
Christian.
[0] https://www.mediawiki.org/wiki/Manual:Short_URL/Apache
On Mon, 5 May 2025, Christian Kujau wrote:
Yes, it was some Rewrite snafu after all. Installed a fresh Mediawiki on the same machine with a different path, and as soon as I enabled the ShortURL hacks the same thing happened.
FWIW, I still find the "error message" kinda confusing: HTTP/200 for GET, but HTTP/404 for POST, I didn't know where to go from here. But, strace(1) was able to shed some light:
$ sudo strace -tt --decode-pids=comm -s1024 -f -o /tmp/foo \ -p $(echo $(pgrep php) $(pgrep apache) | sed 's/ /,/g')
I did not know wether Apache or PHP-FPM was actually triggering the HTTP/404 so I straced both process groups. And there it was:
3644181<apache2> 00:15:12.341845 newfstatat(AT_FDCWD, "/var/www/wiki/Special:Upload", <unfinished ...> 3644187<apache2> 00:15:12.341864 epoll_wait(25, <unfinished ...> 3644181<apache2> 00:15:12.341890 <... newfstatat resumed>0x76c09e71ba60, 0) = -1 ENOENT (No such file or directory) 3644181<apache2> 00:15:12.341929 newfstatat(AT_FDCWD, "/var", {st_mode=S_IFDIR|0755, st_size=70, ...}, AT_SYMLINK_NOFOLLOW) = 0 3644181<apache2> 00:15:12.342006 newfstatat(AT_FDCWD, "/var/www", {st_mode=S_IFDIR|0755, st_size=124, ...}, AT_SYMLINK_NOFOLLOW) = 0AT_SYMLINK_NOFOLLOW) = 0 3644181<apache2> 00:15:12.342147 newfstatat(AT_FDCWD, "/var/www/wiki", 0x76c09e71ba60, AT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)
But /var/www/wiki does not exist, only /var/www/mediawiki does, so in the end that ticked me off that all this was caused by that ShortURL hackery.
Oh well, it works now :-)
This is just a hunch, but $wgFileExtensions does not contain "gif" as an allowed extension for uploading.
https://www.mediawiki.org/wiki/Manual:$wgFileExtensions
On Sun, May 4, 2025 at 5:53 PM Christian Kujau lists@nerdbynature.de wrote:
Hello list,
for some reason I'm no longer able to use the upload function on my little Mediawiki installation. I haven't uploaded things a while, and recently updated to 1.43.1, and everything else appears to work quite well, except uploads. So, I navigate to Special:Upload and in the Apache web server log I can see (shortened, w/o IP adresses and user information):
"GET /wiki/Special:Upload HTTP/2.0" 200 5795 "-" "Mozilla...
Great, HTTP/200 looks good, and the "Upload file" page is being displayed, and I click on "choose file" and select a .gif and the .gif is displayed now displayed as a little preview in the "Source file" part of the Upload page. But then I hit the "Upload file" at the bottom of the page and get a "Not Found" message in my browser window. And the same Apache web server log now has:
"POST /wiki/Special:Upload HTTP/2.0" 404 291 " https://foo.example.org/wiki/Special:Upload" "Mozilla...
So, GET works just fine, but POST produces a HTTP/404?
I've disabled mod_security, disabled all CSP and X-XSS-Protection etc. headers too, but I'm at a loss on how to debug this further.
In my virtual host configuration of the Apache web server, the following is included:
RewriteRule ^/wiki/(.+)?$ /mediawiki/index.php [L]
This worked quite well over the years, and I *was* able to upload stuff before, and with that configuration too.
Attached below is my (shortened) LocalSettings.php (w/o some database secrets and names).
Has anybody seen something like this before, and maybe even remembers where to look to debug this?
Thank you, Christian.
===== LocalSettings.php $wgSitename = "foo"; $wgScriptPath = "/mediawiki"; # real path $wgArticlePath = "/wiki/$1"; # virtual path $wgUsePathInfo = true; # ? $wgServer = "https://foo.example.org"; $wgEnotifUserTalk = true; # UPO $wgEnotifWatchlist = true; # UPO $wgEmailAuthentication = true; $wgDBtype = "mysql"; $wgDBserver = "127.0.0.1"; $wgDBname = "foo"; $wgDBuser = "foo"; $wgDBpassword = "xxxx"; $wgDBprefix = ""; $wgMainCacheType = CACHE_ACCEL; $wgCachePages = true; $wgParserCacheExpireTime = 604800; $wgUseFileCache = true; $wgEnableSidebarCache = true; $wgShowIPinHeader = false; $wgEnableUploads = true; $wgUseImageMagick = true; $wgImageMagickConvertCommand = "/usr/bin/convert"; $wgShellLocale = "en_US.utf8"; $wgCacheDirectory = "$IP/cache"; $wgFileCacheDirectory = "$wgCacheDirectory/html"; $wgLanguageCode = "en"; $wgSecretKey = "xxxx"; $wgUpgradeKey = "xxx"; $wgDefaultSkin = "Vector"; $wgDiff3 = "/usr/bin/diff3"; $wgGroupPermissions['*']['read'] = true; $wgGroupPermissions['*']['edit'] = false; $wgGroupPermissions['*']['createaccount'] = false; $wgNoFollowLinks = false; $wgNamespacesWithSubpages[NS_MAIN] = true; $wgAllowExternalImages = true; $wgAllowCopyUploads = true; $wgCopyUploadsFromSpecialUpload = true; $wgFileExtensions = array_merge($wgFileExtensions, array( 'pdf', 'txt', 'gz', 'bz2', 'deb', 'zip', 'svg', 'diff', 'json' )); $wgVerifyMimeType = false; $wgDisableUploadScriptChecks = true; $wgExtraNamespaces = array( $wgNamespacesWithSubpages[NS_FOO] = true; $wgNamespacesWithSubpages[NS_FOO] = true; $wgShowExceptionDetails = true; $wgDevelopmentWarnings = true; $wgSitemapNamespaces = array( 0, 4, 12 ); $wgAllowTitlesInSVG = true; $wgSVGConverter = 'ImageMagick'; wfLoadSkin('Vector'); wfLoadSkin('MinervaNeue'); wfLoadSkin('Timeless');
-- BOFH excuse #308:
CD-ROM server needs recalibration _______________________________________________ MediaWiki-l mailing list -- mediawiki-l@lists.wikimedia.org To unsubscribe send an email to mediawiki-l-leave@lists.wikimedia.org
https://lists.wikimedia.org/postorius/lists/mediawiki-l.lists.wikimedia.org/
Gif is included by default and they are adding to the default values, so gif is in there.
If a file extension didnt match the list it would still give a 200 status code, just with an error message, and not a 404.
On Sunday, 4 May 2025, Jeffrey T. Darlington jeff.darlington@gmail.com wrote:
This is just a hunch, but $wgFileExtensions does not contain "gif" as an allowed extension for uploading.
https://www.mediawiki.org/wiki/Manual:$wgFileExtensions
On Sun, May 4, 2025 at 5:53 PM Christian Kujau lists@nerdbynature.de wrote:
Hello list,
for some reason I'm no longer able to use the upload function on my little Mediawiki installation. I haven't uploaded things a while, and recently updated to 1.43.1, and everything else appears to work quite well, except uploads. So, I navigate to Special:Upload and in the Apache web server log I can see (shortened, w/o IP adresses and user information):
"GET /wiki/Special:Upload HTTP/2.0" 200 5795 "-" "Mozilla...
Great, HTTP/200 looks good, and the "Upload file" page is being displayed, and I click on "choose file" and select a .gif and the .gif is displayed now displayed as a little preview in the "Source file" part of the Upload page. But then I hit the "Upload file" at the bottom of the page and get a "Not Found" message in my browser window. And the same Apache web server log now has:
"POST /wiki/Special:Upload HTTP/2.0" 404 291 " https://foo.example.org/wiki/Special:Upload" "Mozilla...
So, GET works just fine, but POST produces a HTTP/404?
I've disabled mod_security, disabled all CSP and X-XSS-Protection etc. headers too, but I'm at a loss on how to debug this further.
In my virtual host configuration of the Apache web server, the following is included:
RewriteRule ^/wiki/(.+)?$ /mediawiki/index.php [L]
This worked quite well over the years, and I *was* able to upload stuff before, and with that configuration too.
Attached below is my (shortened) LocalSettings.php (w/o some database secrets and names).
Has anybody seen something like this before, and maybe even remembers where to look to debug this?
Thank you, Christian.
===== LocalSettings.php $wgSitename = "foo"; $wgScriptPath = "/mediawiki"; # real path $wgArticlePath = "/wiki/$1"; # virtual path $wgUsePathInfo = true; # ? $wgServer = "https://foo.example.org"; $wgEnotifUserTalk = true; # UPO $wgEnotifWatchlist = true; # UPO $wgEmailAuthentication = true; $wgDBtype = "mysql"; $wgDBserver = "127.0.0.1"; $wgDBname = "foo"; $wgDBuser = "foo"; $wgDBpassword = "xxxx"; $wgDBprefix = ""; $wgMainCacheType = CACHE_ACCEL; $wgCachePages = true; $wgParserCacheExpireTime = 604800; $wgUseFileCache = true; $wgEnableSidebarCache = true; $wgShowIPinHeader = false; $wgEnableUploads = true; $wgUseImageMagick = true; $wgImageMagickConvertCommand = "/usr/bin/convert"; $wgShellLocale = "en_US.utf8"; $wgCacheDirectory = "$IP/cache"; $wgFileCacheDirectory = "$wgCacheDirectory/html"; $wgLanguageCode = "en"; $wgSecretKey = "xxxx"; $wgUpgradeKey = "xxx"; $wgDefaultSkin = "Vector"; $wgDiff3 = "/usr/bin/diff3"; $wgGroupPermissions['*']['read'] = true; $wgGroupPermissions['*']['edit'] = false; $wgGroupPermissions['*']['createaccount'] = false; $wgNoFollowLinks = false; $wgNamespacesWithSubpages[NS_MAIN] = true; $wgAllowExternalImages = true; $wgAllowCopyUploads = true; $wgCopyUploadsFromSpecialUpload = true; $wgFileExtensions = array_merge($wgFileExtensions, array( 'pdf', 'txt', 'gz', 'bz2', 'deb', 'zip', 'svg', 'diff', 'json' )); $wgVerifyMimeType = false; $wgDisableUploadScriptChecks = true; $wgExtraNamespaces = array( $wgNamespacesWithSubpages[NS_FOO] = true; $wgNamespacesWithSubpages[NS_FOO] = true; $wgShowExceptionDetails = true; $wgDevelopmentWarnings = true; $wgSitemapNamespaces = array( 0, 4, 12 ); $wgAllowTitlesInSVG = true; $wgSVGConverter = 'ImageMagick'; wfLoadSkin('Vector'); wfLoadSkin('MinervaNeue'); wfLoadSkin('Timeless');
-- BOFH excuse #308:
CD-ROM server needs recalibration _______________________________________________ MediaWiki-l mailing list -- mediawiki-l@lists.wikimedia.org To unsubscribe send an email to mediawiki-l-leave@lists.wikimedia.org https://lists.wikimedia.org/postorius/lists/mediawiki-l. lists.wikimedia.org/
mediawiki-l@lists.wikimedia.org