Caddy routes not working

1. Caddy version (caddy version): V.2.3.0

2. How I run Caddy:

sudo systemctl start caddy

a. System environment:

ubuntu 18.04

b. Command:

sudo systemctl start caddy

c. Service/unit/compose file:

Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane.

d. My complete Caddyfile or JSON config:

:80 {

root * /var/www/html
file_server
}

:80/administracion/* {
 uri strip_prefix /administracion
 root * /var/www/html/smiled-front/dist
 file_server
 }

3. The problem I’m having:

:80/administracion not working, getting 404 error in browser console.

4. Error messages and/or full log output:

404 error

5. What I already tried:

:80 {
    root * /var/www/html
    file_server
   route /administracion/* {
      uri strip_prefix /administracion
      root * /var/www/html/smiled-front/dist
      file_server
   }

}

6. Links to relevant resources:

This should work just fine.

What request are you trying to make exactly? Show us with curl -v what it looks like.

What do you see in your logs? Try enabling the debug global option to see more details in the logs as to what the file server handler is doing. Add this to the top of your Caddyfile.

{
    debug
}

Also, you can shorten the route + uri strip_prefix to just handle_path, which has built-in prefix stripping logic. Will save you a line of config.

1 Like

handle_path works just fine!!..thank you!!

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