Custom Caddy Build Issue

1. The problem I’m having:

I am trying to install Caddy with the Cloudflare DNS plugin. The process I’ve gone through is:

  • Installed standard package first as per steps here.
  • Downloaded custom build with following command.
curl -o caddy "https://caddyserver.com/api/download?os=linux&arch=amd64&p=github.com%2Fcaddy-dns%2Fcloudflare&idempotency=98480474495547"
  • Followed Package support files for custom builds for Debian/Ubuntu/Raspbian steps outlined here to insert the custom caddy build.
  • Couldn’t restart the service with final command from above steps.
  • Eventually worked out that granting rwx permissions for caddy group to /usr/bin/caddy allowed the service to run.

2. Error messages and/or full log output:

PASTE OVER THIS, BETWEEN THE ``` LINES.
Sorry I no longer have the exact error but basically permission denied.

3. Caddy version:

v2.7.6 h1:w0NymbG2m9PcvKWsrXO6EEkY9Ru4FJK8uQbYcev1p3A=

4. How I installed and ran Caddy:

a. System environment:

Ubuntu Server 2022.04
x64
systemd
Virtualised in Proxmox

b. Command:

As per above linked instructions.

c. Service/unit/compose file:

GNU nano 6.2                                                                                       /lib/systemd/system/caddy.service
# 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:


# 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.

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

        # 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
}

# Refer to the Caddy docs for more information:
# https://caddyserver.com/docs/caddyfile


5. Links to relevant resources:

NA

I’m a noob with Linux and Caddy. While I appear I’ve fixed it, I expect not. Seeking guidance on issues introduced with my workaround.

Your custom binary shouldn’t be at /usr/bin/caddy after doing the diversion. But yeah, you need to give x to the binary after downloading it, it doesn’t gain permissions immediately after download. Doing chmod +x on the file is enough.

2 Likes

Thank you. Clean install and making that downloaded file executable made following the instructions work es expected.

3 Likes

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