From 03e0cd2fbdf30dfec2aa700ed41fa9041336b97d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Sun, 26 Nov 2023 02:59:36 +0100 Subject: [PATCH] mediawiki: switch to nginx --- hosts/mediawiki/default.nix | 54 +++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/hosts/mediawiki/default.nix b/hosts/mediawiki/default.nix index b10db27f..bed479ef 100644 --- a/hosts/mediawiki/default.nix +++ b/hosts/mediawiki/default.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, lib, libC, pkgs, ... }: let cfg = config.services.mediawiki; @@ -67,37 +67,27 @@ in sha256 = "sha256-N1+OV1UdzvU4iXhaS/+fuEoAXqrkVyyEPDirk0vrT8A="; }; }; - httpd.virtualHost = { - adminAddr = "no-reply@c3d2.de"; - enableACME = true; - forceSSL = true; - hostName = "wiki.c3d2.de"; - extraConfig = '' - RewriteEngine On - RewriteRule ^/w/(.*).php /$1.php [L,QSA] - RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f - RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d - RewriteCond %{REQUEST_URI} !^/images - RewriteRule ^(.*) /index.php/$1 [L,QSA] - ''; - }; + + name = "C3D2"; + nginx.hostName = "wiki.c3d2.de"; #skins = { # Vector = "${config.services.mediawiki.package}/share/mediawiki/skins/Vector"; # Hector = "${config.services.mediawiki.package}/share/mediawiki/skins/Hector"; #}; - name = "C3D2"; # initial admin user password passwordFile = config.sops.secrets."mediawiki/adminPassword".path; uploadsDir = "/var/lib/mediawiki/uploads"; + webserver = "nginx"; extraConfig = /* php */ '' - $wgArticlePath = '/$1'; - - $wgShowExceptionDetails = true; - $wgDBserver = "${config.services.mediawiki.database.socket}"; + $wgAllowUserCss = true; $wgDBmwschema = "mediawiki"; + $wgEnableAPI = true; + $wgEnableMWSuggest = true; + $wgShowExceptionDetails = true; + $wgUseAjax = true; $wgLogo = "https://www.c3d2.de/images/ck.png"; $wgEmergencyContact = "wiki@c3d2.de"; @@ -160,18 +150,9 @@ in $wgCaptchaClass = 'QuestyCaptcha'; $wgCaptchaQuestions[] = array( 'question' => 'How is C3D2 logo in ascii?', 'answer' => '<<>' ); - # we are using the feature of the default extension interwiki for linking to other articles of the same domain - # https://www.mediawiki.org/wiki/Extension:Interwiki - # without loading this extension there is no page Spezial:Interwikitablle (aka Special:Interwiki) to manage the table of entries for interwiki links wfLoadExtension( 'Interwiki' ); - # all members of the sysop group should be able to manage entries for interwiki links $wgGroupPermissions['sysop']['interwiki'] = true; - $wgEnableAPI = true; - $wgAllowUserCss = true; - $wgUseAjax = true; - $wgEnableMWSuggest = true; - wfLoadExtension('Cite'); wfLoadExtension('CiteThisPage'); wfLoadExtension('ConfirmEdit'); @@ -191,6 +172,19 @@ in ''; }; + nginx = { + enable = true; + commonHttpConfig = '' + # for some reason nginx adds a port for the 301 redirect from / to /wiki/ + port_in_redirect off; + ''; + virtualHosts."wiki.c3d2.de" = { + enableACME = true; + forceSSL = true; + listen = libC.defaultListen; + }; + }; + phpfpm.phpPackage = pkgs.php.buildEnv { extensions = { all, enabled }: enabled ++ (with all; [ apcu ]); }; @@ -203,7 +197,7 @@ in ensurePermissions = { "DATABASE ${cfg.database.name}" = "ALL PRIVILEGES"; }; }]; package = pkgs.postgresql_16; - upgrade.stopServices = [ "httpd" "phpfpm-mediawiki" ]; + upgrade.stopServices = [ "phpfpm-mediawiki" ]; }; };