Noob to Caddy, receiving 404 error on sub paths

1. The problem I’m having:

I am a noob with Caddy. I am attempting to have Caddy serve a static Vue app. When I issue a request to https://fiddleshows.fiddlemon.com everything works correctly. However if I issue a request with any sub pages, for example https://fiddleshows.fiddlemon.com/tabs/my-shows, the server returns a 404 error.

What needs to be changed to eliminate the 404 error?

2. Error messages and/or full log output:

The server returns a 404 error when any sub pages are included in the request

3. Caddy version:

v2.7.6

4. How I installed and ran Caddy:

> sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
> curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
> curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
> sudo apt update
> sudo apt install caddy

a. System environment:

Ubuntu 22.04.4 LTS

b. Command:

sudo systemctl start caddy

c. Service/unit/compose file:

# caddy.service
#
# For using Caddy with a config file.
#
# Make sure the ExecStart and ExecReload commands are correct
# for your installation.
#
# See https://caddyserver.com/docs/install for instructions.
#
# WARNING: This service does not use the --resume flag, so if you
# use the API to make changes, they will be overwritten by the
# Caddyfile next time the service is restarted. If you intend to
# use Caddy's API to configure it, add the --resume flag to the
# `caddy run` command or use the caddy-api.service file instead.

[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Requires=network-online.target

[Service]
Type=notify
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile --force
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target

d. My complete Caddy config:

fiddleshows.fiddlemon.com {
root * /home/ubuntu/FiddleShows/
    file_server
    log {
		output file /var/log/caddy/access.log
	}
}

5. Links to relevant resources:

See Common Caddyfile Patterns — Caddy Documentation, you probably need try_files to have Caddy rewrite requests to unknown files to your index.

You shouldn’t be serving your app from /home, it can typically cause file permission issues. Move your site to /srv or /var/www/html instead.

1 Like

Thanks, try_files, solved the problem.

1 Like

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