Page MenuHomePhabricator

Allow DefaultSettings to be overriden by environment variables
Open, Needs TriagePublic

Description

It would be helpful if the DefaultSettings could be overridden by environment variables. This would allow users to set the defaults for all wiki's on a system, but would also let easy configuration within a docker container or vagrant, etc. And would make MediaWiki closer to becoming a 12-factor app.

You would still be able to override the defaults with LocalSettings.php. However, a LocalSettings.php would technically not be required at all.

The order would be something like this:
DefaultSettings.php -> Environment Variables (if set) -> LocalSettings.php

The environment variables should take on the same pattern as the variable names for example:
$wgStyleSheetPath would become MEDIAWIKI_STYLE_SHEET_PATH or if we want to get the wg then it would be WG_STYLE_SHEET_PATH, but I think MEDIAWIKI_ is a better prefix.

Event Timeline

dbarratt created this task.Aug 23 2017, 4:34 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 23 2017, 4:34 PM
dbarratt updated the task description. (Show Details)Aug 23 2017, 4:37 PM
Tgr added a subscriber: Tgr.Aug 23 2017, 6:05 PM

In the past we used to get some settings via environment variables like HTTP_PROXY but that turned out to be a security issue: https://httpoxy.org/

I'd rather see us implement something like T115432: Get MW_CONFIG_FILE from env to facilitate virtual hosting - would that address your use-case?

I'd rather see us implement something like T115432: Get MW_CONFIG_FILE from env to facilitate virtual hosting - would that address your use-case?

Unfortunately it doesn't because in the case of Docker, the LocalSettings.php would still need to be in the container and there's no way to put it there unless the user mounts the file from the host or goes into the container and copy it in. But that's the same as they are doing now, so it doesn't make it any easier.

I would like to be able to alter the configuration from outside of the container, which can only be done with environment variables (afaik).

kostajh added a subscriber: kostajh.Jan 3 2020, 8:46 AM

In the past we used to get some settings via environment variables like HTTP_PROXY but that turned out to be a security issue: https://httpoxy.org/

That seems specific to that environment variable, though, unless I'm missing something. @Legoktm do you have broader concerns with using environment variables? If not, could we talk about what the specific implementation could look like (proposal in task description looks good to me) so that work could start on patches?

brennen moved this task from Backlog to Watching on the User-brennen board.
brennen added a subscriber: brennen.