Can't configure caddyserver v2 for dokuwiki with example provided

1. Caddy version (v2):

2. How I run Caddy:

add repo fury
debian apt install caddy

a. System environment:

debian raspbian

b. Command:

sudo service caddy restart

c. Service/unit/compose file:

paste full file contents here

d. My complete Caddyfile or JSON config:

paste config here, replacing this text
DO NOT REDACT anything except credentials

3. The problem I’m having:

I am trying to configure dokuwiki with caddyserver.

I found this example :

If anyone can advise

4. Error messages and/or full log output:

5. What I already tried:

I managed to adapt it to v2 a bit but I am stuck with the last one :
#rewrite {

if {path} not_match /lib/.*

if {path} not_match /forbidden

r /(.*)

to {uri} /doku.php?id={1}&{query}

#}

Those ones I transforms without error when lauching the service but still hasn’t got any wiki running :frowning:

php_fastcgi / unix//var/run/php-fpm/php-fpm.sock
rewrite /(data/|conf/|bin/|inc/|install.php) /forbidden
rewrite /_media(. ) /lib/exe/fetch.php?media={1}
rewrite /_detail(.
) /lib/exe/detail.php?media={1}
rewrite / export/([^/]+)/(.) /doku.php?do=export* {1}&id={2}

6. Links to relevant resources:

Thanks !!

Hi @Guiz, welcome to the Caddy community!

Your configs are a bit hard to read. Would you mind editing your post to set your configs as preformatted text? You can select the whole config and then click this button in the editor:

Screen Shot 2020-06-08 at 2.42.25 pm

Alternately, you can start and end your code blocks with triple backticks on their own lines (```).

I note also that the matchers you’re using are exact, but you’ve got regex characters in there. Matchers don’t support regex syntax; you’ll need to use a named matcher for that: Request matchers (Caddyfile) — Caddy Documentation

1 Like

I am using this configuration and all seems to work.

root * /srv/{host}
php_fastcgi localhost:9000
file_server

encode zstd gzip

@restrict_files {
  path /data/* /conf/* /bin/* /inc/* /vendor/* /install.php
}

@allow_media    {
  path /_media*
}

@allow_detail   {
  path /_detail*
}

@allow_export   {
  path /_export*
  path_regexp export /([^/]+)/(.*)
}

respond @restrict_files 404
rewrite @allow_media  /lib/exe/fetch.php?media={path}
rewrite @allow_detail /lib/exe/detail.php?media={path}
rewrite @allow_export /doku.php?do=export_{http.regexp.export.1}&id={http.regexp.export.2}
try_files {path} {path}/ /doku.php?id={path}&{query}

I so far have not had a problem.

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.