I have a DokuWiki set up in NGINX served in a directory. Due to preexisting conditions with moving from another webserver, this wiki has, and needs to retain, userewrite=2
. Resulting URLs are of the form http://foo.wiki/doku.php/Foo
.
The problem comes from uploaded images (external images are fine, mysteriously enough). Images appear as empty boxes in the rendered page, and when clicking the details link, the browser is redirected to a non-existent article with the pattern lib/exe/fetch.php/${medianame}?${query}
. So trying to click on the details for bar.png leads to the article lib/exe/fetch.php/bar.png?w=200
, for example.
The URLs that DokuWiki is generating, according to the NGINX logs and in accordance to what is observer in the browser bar, are as follows:
Image --> http://foo.wiki/lib/exe/fetch.php/medianame.png?w=300&etc...
Details --> http://foo.wiki/lib/exe/detail.php/medianame.png?id=original%3Aarticle
My NGINX configuration is drawn from the base example as follows:
server {
server_name foo.wiki;
root foo/doku; # this is where eg.: doku.php lives
index index.php index.html;
include inc/foo_favicon;
# Dokuwiki
location / { try_files $uri $uri/ @dokuwiki; }
location @dokuwiki {
rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
# [1] it seems this rule is needed for userewrite=2 to work?
rewrite ^/doku.php/(.+) /doku.php?id=$1&$args? last;
rewrite ^/(.*) /doku.php?id=$1 last;
}
location ~ /(conf|bin|inc|vendor)/ {
deny all;
}
location ~ /data/ {
internal;
}
location ~ \.php$ {
if (!-f $request_filename) { return 404; }
include inc/fastcgi_script;
fastcgi_pass foo_php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
I had to add the rule pointed to in "[1]" since otherwise the wiki would not load with userewrite=2
, but I'm open to refining the rule if it helps.
My one remaining issue is that for uploaded media only, fetching seems to fail. I don't know well how to diagnose the issue - let alone given external media works perfectly. Given the userewrite configuration, do I need further location { }
blocks in order to make it work? If I manually write the URLs in the form the rewrite already uses (eg.: /_media/medianame.png
, it works (it goes through the rewrite), but I don't know how to force the DokuWiki renderer to generate the URLs with this structure.
Glad in advance for any help.