Caddy refuses to start or stop

1. Caddy version (caddy version):

V2.5.2

2. How I run Caddy:

Using with Rocketchat server as reverse proxy (Snap from Ubuntu server 22.04). Removed whatever instance of Caddy was already included since it wouldn’t start or stop, added repository for Caddy and installed it fresh thinking that might help.

a. System environment:

Ubuntu Server 22.04 fresh install, installed Caddy using Snap during the server setup process. Maybe the Snap package isn’t worth using?

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:

# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace ":80" below with your
# domain name.

wowsers.duckdns.org {
	# Set this path to your site's directory.
	root * /var/snap/rocketchat-server/1520/ {
		# 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
	}
}

3. The problem I’m having:

Caddy refuses to start or stop.

4. Error messages and/or full log output:

$ systemctl status caddy.service
× caddy.service - Caddy
     Loaded: loaded (/lib/systemd/system/caddy.service; enabled; vendor preset: enabl>
     Active: failed (Result: exit-code) since Fri 2022-07-15 01:52:32 UTC; 1min 13s a>
       Docs: https://caddyserver.com/docs/
    Process: 13381 ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfi>
   Main PID: 13381 (code=exited, status=1/FAILURE)
        CPU: 29ms

Jul 15 01:52:32 ubuntu-server caddy[13381]: LOGNAME=caddy
Jul 15 01:52:32 ubuntu-server caddy[13381]: USER=caddy
Jul 15 01:52:32 ubuntu-server caddy[13381]: INVOCATION_ID=e72cd2c501b24a1e8e0747cd7c6>
Jul 15 01:52:32 ubuntu-server caddy[13381]: JOURNAL_STREAM=8:44712
Jul 15 01:52:32 ubuntu-server caddy[13381]: SYSTEMD_EXEC_PID=13381
Jul 15 01:52:32 ubuntu-server caddy[13381]: {"level":"info","ts":1657849952.6782744,">
Jul 15 01:52:32 ubuntu-server caddy[13381]: run: adapting config using caddyfile: par>
Jul 15 01:52:32 ubuntu-server systemd[1]: caddy.service: Main process exited, code=ex>
Jul 15 01:52:32 ubuntu-server systemd[1]: caddy.service: Failed with result 'exit-cod>
Jul 15 01:52:32 ubuntu-server systemd[1]: Failed to start Caddy.
$ journalctl -xeu caddy.service
Jul 15 01:52:32 ubuntu-server caddy[13381]: INVOCATION_ID=e72cd2c501b24a1e8e0747cd7c6>
Jul 15 01:52:32 ubuntu-server caddy[13381]: JOURNAL_STREAM=8:44712
Jul 15 01:52:32 ubuntu-server caddy[13381]: SYSTEMD_EXEC_PID=13381
Jul 15 01:52:32 ubuntu-server caddy[13381]: {"level":"info","ts":1657849952.6782744,">
Jul 15 01:52:32 ubuntu-server caddy[13381]: run: adapting config using caddyfile: par>
Jul 15 01:52:32 ubuntu-server systemd[1]: caddy.service: Main process exited, code=ex>
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ An ExecStart= process belonging to unit caddy.service has exited.
░░ 
░░ The process' exit code is 'exited' and its exit status is 1.
Jul 15 01:52:32 ubuntu-server systemd[1]: caddy.service: Failed with result 'exit-cod>
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ The unit caddy.service has entered the 'failed' state with result 'exit-code'.
Jul 15 01:52:32 ubuntu-server systemd[1]: Failed to start Caddy.
░░ Subject: A start job for unit caddy.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A start job for unit caddy.service has finished with a failure.
░░ 
░░ The job identifier is 25659 and the job result is failed.

5. What I already tried:

Rebooted server, tried editing the caddy server file. I’m sorry but I haven’t used Caddy before, so I’m probably noobing it up good and proper in here. :frowning:

6. Links to relevant resources:

I am following the documentation for Snap on Rocketchats website. It appears I cannot post links as a new user.

1 Like

Caddy is failing to run because of a syntax error in your Caddyfile, but your logs are truncated here so you can’t see the full error message.

Yeah, I strongly recommend using our official apt package instead. See here for recommendations on how to use it. Note the command there to see your logs without truncation:

This page?

https://docs.rocket.chat/quick-start/deploying-rocket.chat/rapid-deployment-methods/snaps/auto-ssl-with-snaps

Apparently they ship Caddy along with their snap. I wasn’t aware of that. It seems like they configure Caddy via some snap variables I guess. So maybe do that.

But either way, your current config doesn’t make sense, because you want to reverse_proxy to rocket chat, not root + file_server.

1 Like

Thanks for your reply. I guess my description is confusing now that I re-read it because I did indeed completely remove the instance of Caddy that came with the Rocketchat Snap package, and installed a fresh Caddy instance from the repository thinking that would help. But so far Caddy will not start.

I guess I need help understanding what is wrong with the syntax of my Caddy file, if that is indeed the problem. Which it very well may be, as you suggest.

My goal is to get Caddy service to start so I can then configure a lets encrypt certificate and start using my Rocketchat server.

Here is my Caddyfile:

wowsers.duckdns.org {
	# Set this path to your site's directory.
	root * /var/snap/rocketchat-server/1520/ {
		# 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
	}
}

Remove all the stuff within the site block.

As far as I understand, you want a reverse_proxy config, not file_server. Read the rocketchat docs, it explains.

wowsers.duckdns.org {
    reverse_proxy localhost:3000
}

Yes, you were right! Thank You Very Much! :100: :raised_hands:

1 Like

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