Page MenuHomePhabricator

MediaWiki entry points should not be in the base repo directory
Open, Needs TriagePublic

Description

This has come up in a few places (T167038, T180237), but as far as I know no one has filed a task specifically for the idea.

Problem statement

Currently, MediaWiki's main entry points such as index.php, api.php, and load.php are in the repository's base directory. This makes it very difficult for anyone installing MediaWiki to follow good security practices and expose only the entry points via the web server, with all non-entry-point files stored elsewhere.

Solution (draft)

We should, instead, place these files in a subdirectory (name it "webroot" or "www" or "public_html", bikeshed later).

The drawback is that installation becomes more complex. Instead of just dumping MediaWiki into /var/www (or equivalent), someone has to set up symbolic links or configure the web server to serve MediaWiki's virtual base path from a different location, not only for the webroot itself but also for the various resources pointed to by configuration settings such as $wgResourceBasePath ($wgExtensionAssetsPath, and $wgStylePath), and $wgUploadPath.

Event Timeline

The drawback is that installation becomes more complex.

As long as you don't care of the security benefits, not really. If you dump a tarball into /var/www, MediaWiki will be available as example.com/index.php. If we move the entry points into, say, a directory called w, it will be available as example.com/w/index.php. No configuration needed. It will be a thorough BC break for existing installations, of course.

OTOH anyone who cares much about security has probably set up MediaWiki via symlinks or whatever; moving the entry points makes that marginally more convenient, at most (you need slightly less symlinks, but you still need to deal with assets which is the more problematic part).

If we want to support convenient non-webroot installation, that would probably require some mechanism to copy assets from core and skins/extensions into the webroot, and also set up entry point redirects there.

If we want to support convenient non-webroot installation, that would probably require some mechanism to copy assets from core and skins/extensions into the webroot, and also set up entry point redirects there.

Another option could be to just proxy the rest of the assets that aren't JS/CSS through load.php anyways so skins/extensions never need to be in the webroot themselves. (And then replace debug mode somehow)

Replacing debug mode needs to happen anyway :)

@Anomie This seems ready for an IRC discussion. Does that sound useful to you? And do you have a preferred time slot for the discussion?

I file this mainly because it kept getting mentioned but we didn't have a task for it. I'd be happy for someone else to actually push it forward.

@Anomie ok, i'll put it in "under discussion" for now