Beginner step by step configure Caddy2 reverse proxy

1. My Caddy version (caddy version):

v2.0.0-rc.3

2. How I run Caddy:

Proxmox - VM (1 core - 512mb RAM)

a. System environment:

Ubuntu 18.04 LTS

b. Command:

c. Service/unit/compose file:

d. My complete Caddyfile or JSON config:

Don’t have

3. The problem I’m having:

4. Error messages and/or full log output:

5. What I already tried:

This is my first reverse proxy in my life and I’m struggling to configure caddy2.

I installed Ubuntu 18.04LTS, after that I get the zip from github with a curl command. I extract it, move it to my path (sudo mv caddy /usr/bin/), I create a group caddy, I make a user name caddy and that’s all.

After this steps I’m lost. I don’t understand what I have to do anymore.
I need to create a file?

Next, choose a systemd service file based on your use case:

  • caddy.service if you configure Caddy with a file.
  • caddy-api.service if you configure Caddy solely through its API.

Can someone kind give me a some help?

Thanks.

6. Links to relevant resources:

What kind of help are you looking for, exactly?

Are you having trouble figuring out which service file to choose? If you don’t know the difference between the two, the correct answer for you is likely to be caddy.service (for if you configure Caddy with a file).

Are you having trouble figuring out where to put the file? It needs to go with the other systemd unit files to be loaded. Here’s a thread with some more info on that: directory structure - Where do I put my systemd unit file? - Unix & Linux Stack Exchange


You’re quoting from the installation docs (Install — Caddy Documentation), which is already the place to find a step-by-step installation process.

A guide for writing configuration for a reverse proxy can be found here: Reverse proxy quick-start — Caddy Documentation

1 Like

I create a file caddy.service in /lib/systemd/system/.
The caddy file is in /usr/bin/

I get this error when I’m running this command:vp@proxy:~$ systemctl status caddy
● caddy.service - Caddy
Loaded: loaded (/lib/systemd/system/caddy.service; enabled; vendor preset: en
Active: failed (Result: exit-code) since Wed 2020-04-15 14:55:51 UTC; 8s ago
Docs: Welcome — Caddy Documentation
Process: 1426 ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddy
Main PID: 1426 (code=exited, status=1/FAILURE)

Apr 15 14:55:51 proxy caddy[1426]: LANG=en_US.UTF-8
Apr 15 14:55:51 proxy caddy[1426]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin
Apr 15 14:55:51 proxy caddy[1426]: HOME=/var/lib/caddy
Apr 15 14:55:51 proxy caddy[1426]: LOGNAME=caddy
Apr 15 14:55:51 proxy caddy[1426]: USER=caddy
Apr 15 14:55:51 proxy caddy[1426]: INVOCATION_ID=59a126d96f0e4fe9b079d84e71ab7d9
Apr 15 14:55:51 proxy caddy[1426]: JOURNAL_STREAM=9:21884
Apr 15 14:55:51 proxy caddy[1426]: run: reading config file: open /etc/caddy/Cad
Apr 15 14:55:51 proxy systemd[1]: caddy.service: Main process exited, code=exite
Apr 15 14:55:51 proxy systemd[1]: caddy.service: Failed with result ‘exit-code’.
lines 1-17/17 (END)

What I’m doing wrong?

What is the contents of this file?

Also, can you post the output from: journalctl -b -u caddy.service --no-pager

The “caddy file”? Are you referring to the Caddyfile (text configuration, which should go in /etc) or are you referring to the caddy binary (which should go in your path, such as /usr/bin)?

My hunch right now is that if you’ve put your Caddyfile configuration in /usr/bin, that’ll be your issue… Depending of course on the service configuration you’re using.

2 Likes

journalctl -b -u caddy.service --no-pager
– Logs begin at Tue 2020-04-14 16:56:19 UTC, end at Thu 2020-04-16 15:53:56 UTC. –
Apr 16 06:44:15 proxy systemd[1]: Started Caddy.
Apr 16 06:44:15 proxy caddy[793]: caddy.HomeDir=/var/lib/caddy
Apr 16 06:44:15 proxy caddy[793]: caddy.AppDataDir=/var/lib/caddy/.local/share/caddy
Apr 16 06:44:15 proxy caddy[793]: caddy.AppConfigDir=/var/lib/caddy/.config/caddy
Apr 16 06:44:15 proxy caddy[793]: caddy.ConfigAutosavePath=/var/lib/caddy/.config/caddy/autosave.json
Apr 16 06:44:15 proxy caddy[793]: runtime.GOOS=linux
Apr 16 06:44:15 proxy caddy[793]: runtime.GOARCH=amd64
Apr 16 06:44:15 proxy caddy[793]: runtime.Compiler=gc
Apr 16 06:44:15 proxy caddy[793]: runtime.NumCPU=1
Apr 16 06:44:15 proxy caddy[793]: runtime.GOMAXPROCS=1
Apr 16 06:44:15 proxy caddy[793]: runtime.Version=go1.14.2
Apr 16 06:44:15 proxy caddy[793]: os.Getwd=/
Apr 16 06:44:15 proxy caddy[793]: LANG=en_US.UTF-8
Apr 16 06:44:15 proxy caddy[793]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
Apr 16 06:44:15 proxy caddy[793]: HOME=/var/lib/caddy
Apr 16 06:44:15 proxy caddy[793]: LOGNAME=caddy
Apr 16 06:44:15 proxy caddy[793]: USER=caddy
Apr 16 06:44:15 proxy caddy[793]: INVOCATION_ID=665ef7ba434c451aa113265bc4cdb191
Apr 16 06:44:15 proxy caddy[793]: JOURNAL_STREAM=9:17643
Apr 16 06:44:15 proxy caddy[793]: {“level”:“info”,“ts”:1587019455.7599587,“msg”:“using provided configuration”,“config_file”:"/etc/caddy/Caddyfile",“config_adapter”:""}
Apr 16 06:44:15 proxy caddy[793]: run: adapting config using caddyfile: EOF
Apr 16 06:44:15 proxy systemd[1]: caddy.service: Main process exited, code=exited, status=1/FAILURE
Apr 16 06:44:15 proxy systemd[1]: caddy.service: Failed with result ‘exit-code’.

Looks like you never created /etc/caddy/Caddyfile. You need a configuration file to run the server!

1 Like

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