Caddy setup via Containerized App: where are site files located

Where are website files located for the Caddy containerized app?

I’ve looked in all of the folders in usb1/apps/caddy. However, I cannot find the index file.

In one of the apps/layers folders, I did find a folder for Caddy and found a nested folder with an index file.

In Winbox, the Container window shows Caddy’s root dir as /usb1/apps/caddy/caddy_root and the working directory as /srv. The root folder has only an /etc folder and I could not find /src anywhere.

I found a caddy config file that has the site’s directory at /usr/share/caddy. That folder is in the apps/layers/a0effe29ade(caddy stuff) folder. Seems odd that the site directory would be in the layers folder instead of the apps/caddy folder.

The Caddy config file should be at:

"$[/app/settings/get disk]/apps/caddy/caddy-config/caddy"

"$[/app/settings/get disk]/apps/caddy/caddy-conf/Caddyfile"

and created by default.

Just to add: it's very common to use caddy only as a reverse proxy, and that's why a "www" directory is not placed by default.

It's a totally fine web server, though. But if it's used as such, the root directory (usually per "virtualhost") is specified with the "root" directive.

EDIT: the directive is called "root"

1 Like

I just tested this out of curiosity. To edit the Caddyfile, use:

/file/edit "$[/app/settings/get disk]/apps/caddy/caddy-conf/Caddyfile" contents 

and that's what you should edit to control Caddy Server.

While the default enables a web server on port 80, with file-server enabled... the problem is the default uses the path /usr/share/caddy as the web server directory. And that is not what's mapped by defaults in MikroTik's /app configuration, which uses /srv inside caddy, and apps/caddy/caddy-site in RouterOS files.

So you need to change the root in the Caddy file, using above edit command:

:80 {
    # Set this path to your site's directory.
    root * /srv

    # Enable the static file server.
    file_server

    # Another common task is to set up a reverse proxy:
    # reverse_proxy localhost:8080

    # Or serve a PHP site through php-fpm:
    # php_fastcgi localhost:9000
}

which will then make the RouterOS path to the www of Caddy server:

"$[/app/settings/get disk]/apps/caddy/caddy-site"

And you test by adding a index.html there:

/file add name="$[/app/settings/get disk]/apps/caddy/caddy-site/index.html" contents="<html><body>Hello</body></html>"

Finally restarting caddy:

/container stop app-caddy
:delay 5s
/container start app-caddy

I appreciate your help. That saved me a lot of time. I never would have figured out the /srv part of the “root * /srv” path.

Would be good if the Mikrotik app configuration could do this as default. Hopefully that is even possible.

Well, the caddyfile syntax is already a really easy shorthand form, so adding an even more intuitive interface sounds like a bit too much. One, however, can always hope...