User Tools

Site Tools


sysadmin:wiki

Setting up this Wiki

Intro

I'm self-hosted, and I want to run a wiki (this) behind a proxy. My front-end is NGINX while the page you are reading is Apache.

From 30,000 feet.

  • NGINX front-end, but when someone passes “mikelivolsi.com/wiki”, the “/wiki” will pass traffic to the back-end server running the wiki.
  • The back-end server is running Apache2
  • The document home for the wiki is /var/www/wiki

Prerequisites

  • Unix firewall (UFW) - or equivalent - should be running and only allow traffic from the front-end nginx site
  • You will need to install the proper php libraries (running php 8.4)
  • Don't follow verbatim ChatGPT or Gemini, as they will make you nuts if you listen to them.

Steps

  • Step 1: sudo to root
  • Step 2: cd /var/www and make the directory wiki
  • Step 3: cd wiki
  • Step 4: get the latest copy: curl -o doku.tgz https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz
  • Step 5: Extract the wiki: tar -xzvf doku.tgz
  • Step 6: Rename the resulting directory: mv dokuwiki-2025-05-14b dokuwiki
  • Step 7: change ownership to www-data:www-data for everything under /var/www/wiki
  • Step 8: cd /etc/apache2/sites-available
  • Step 9: Create a file called wiki.conf and make sure it looks similar to the following:
  <VirtualHost *:xxxx>
    ServerAdmin webmaster@localhost
    ServerName  wiki.mikelivolsi.com

    DocumentRoot /var/www/wiki/dokuwiki

    DirectoryIndex doku.php index.php


    <Directory /var/www/wiki/dokuwiki/>
        Options Indexes FollowSymLinks MultiViews
        Require all granted
        AllowOverride All
        DirectoryIndex doku.php index.php
    </Directory>

    <IfModule mod_dav.c>
        Dav off
    </IfModule>

    ScriptAlias /cgi-bin/ /var/www/wiki/cgi-bin/

    <Directory "/var/www/wiki/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Require all granted

        AddHandler cgi-script .cgi .pl .py
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/wiki_error.log
    CustomLog ${APACHE_LOG_DIR}/wiki_access.log combined
</VirtualHost>
  • Step 10 - Make configuration visible: a2ensite wiki
  • Step 11 - Edit the docu-wiki configuration: vi /var/www/wiki/conf/dokuwiki.php
  • Step 12 - Make the following changes:
$conf['baseurl'] = '/';
$conf['basedir'] = '/wiki';
$conf['useurlrewriting'] = false;  // keep false for reverse proxy
  • Step 13 - enable re-write if not already enabled: a2enmod rewrite
  • Step 14 - Enable the configuration: systemctl restart apache2
  • Step 15 - Make sure to configure your site with the username, etc.. via your browser
            http://<your ip>/install.php
  • Step 16 - Login to your nginx site
  • Step 17 - cd /etc/nginx/sites-available
  • Step 18 - Before this block, add the subsequent block in this doc, above it !!!
  • »> NOTE «< If should come before any asset declarations, like I had for wordpress:
    # Static assets for WordPress
    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        expires max;
        log_not_found off;
    }
 

My block

    # -------------------------------
    # DokuWiki reverse proxy
    # -------------------------------
    location ^~ /wiki/ {
        proxy_pass http://192.168.1.x:xxxx/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

        # Important for DokuWiki
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Port $server_port;

        proxy_redirect off;
    }

    # Redirect /wiki (no trailing slash)
    location = /wiki {
        return 301 /wiki/;
    }
  • Restart nginx: systemctl restart nginx

Afterwards, if you go to your site.. like “https://www.mikelivolsi.com/wiki” it will take you to your wiki.

Notes

 Certificates are handled by the front-end server, so the back-end can run http
sysadmin/wiki.txt · Last modified: by mlivolsi