Docker Caddy issues

1. Caddy version (caddy version):

v2.4.5

2. How I run Caddy:

docker run -d -p 80:80 -p 443:443
-v /site:/usr/share/caddy
-v caddy_data:/data
-v caddy_config:/config
caddy caddy reverse-proxy --from

a. System environment:

Docker on Ubuntu Server 20.04.2

b. Command:

Docker says caddy is running. i type caddy ‘command’ and get 'caddy: command not found

Paste command here.

c. Service/unit/compose file:

-v /site:/usr/share/caddy \
-v caddy_data:/data \
-v caddy_config:/config \
caddy caddy reverse-proxy --from 

d. My complete Caddyfile or JSON config:

Paste config here, replacing this text.
Use `caddy fmt` to make it readable.
DO NOT REDACT anything except credentials.
LEAVE DOMAIN NAMES INTACT.
Make sure the backticks stay on their own lines.

3. The problem I’m having:

I can’t access caddy from the browser. The page with caddy askew. It’s running in docker and yet i an’t access it.

4. Error messages and/or full log output:

5. What I already tried:

After googling for awile, Don’t know what to try.

6. Links to relevant resources:

Thanks in advanced.

I don’t understand what you mean. Please be more specific. Maybe copy your terminal command and output to show us.

That sounds like you’re seeing Caddy’s default welcome page.

You didn’t give the correct arguments to the caddy reverse-proxy command. See the docs, you need to specify arguments for --from and --to:

What exactly are you trying to do? Your post is very light on details, so it’s impossible to really recommend anything at this point. You’ll need to clarify.

I strongly recommend using a Caddyfile instead of using the caddy reverse-proxy command. It’s much more flexible. That command is meant for spinning up a quick and easy local development server. When running in Docker, you’re better off using an actual config file to instruct Caddy what to do.

If you’re trying to proxy another service, you don’t need this line: -v /site:/usr/share/caddy, because this is mounting the directory /site from your host machine to /usr/share/caddy in the container. If that path doesn’t exist on your host machine, that won’t do anything useful… and also, it’s only useful if you’re trying to serve files using Caddy, i.e. using file_server.

OK. I’ll try to be more specific.

THis is what my container currently looks like.

{
    "AppArmorProfile": "docker-default",
    "Args": [
        "reverse-proxy",
        "--from",
        "jfhomeserver.hopto.org",
        "--to",
        "192.168.1.130:8096"
    ],
    "Config": {
        "AttachStderr": false,
        "AttachStdin": false,
        "AttachStdout": false,
        "Cmd": [
            "caddy",
            "reverse-proxy",
            "--from",
            "jfhomeserver.hopto.org",
            "--to",
            "192.168.1.130:8096"
        ],
        "Domainname": "",
        "Entrypoint": null,
        "Env": [
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
            "CADDY_VERSION=v2.4.5",
            "XDG_CONFIG_HOME=/config",
            "XDG_DATA_HOME=/data",
            "TZ=Etc/UTC"
        ],
        "ExposedPorts": {
            "2019/tcp": {},
            "443/tcp": {},
            "80/tcp": {}
        },
        "Hostname": "d406cdc88ce0",
        "Image": "caddy:latest",
        "Labels": {
            "org.opencontainers.image.description": "a powerful, enterprise-ready, open source web server with automatic HTTPS written in Go",
            "org.opencontainers.image.documentation": "https://caddyserver.com/docs",
            "org.opencontainers.image.licenses": "Apache-2.0",
            "org.opencontainers.image.source": "https://github.com/caddyserver/caddy-docker",
            "org.opencontainers.image.title": "Caddy",
            "org.opencontainers.image.url": "https://caddyserver.com",
            "org.opencontainers.image.vendor": "Light Code Labs",
            "org.opencontainers.image.version": "v2.4.5"
        },
        "OnBuild": null,
        "OpenStdin": false,
        "StdinOnce": false,
        "Tty": false,
        "User": "",
        "Volumes": {
            "/config": {},
            "/data": {},
            "/usr/share/caddy": {}
        },
        "WorkingDir": "/srv"
    },
    "Created": "2021-09-22T15:35:03.403242919Z",
    "Driver": "overlay2",
    "ExecIDs": null,
    "GraphDriver": {
        "Data": {
            "LowerDir": "/var/snap/docker/common/var-lib-docker/overlay2/516ce7231a8a8bc552d4be70e8e80af8ed050a34237a45f6522262a82457facb-init/diff:/var/snap/docker/common/var-lib-docker/overlay2/80eaf6af734e840f1d125a133e4d75fe706f7dcb071f8066e29e26e01efb2732/diff:/var/snap/docker/common/var-lib-docker/overlay2/34f2947c854b2f7f13d84428195b14c9e241887711277c46c0892f1f0e4a55e5/diff:/var/snap/docker/common/var-lib-docker/overlay2/2f7a0276567bd236af30574dc38b44b79d0708bb609982639b9552feee36a9b7/diff:/var/snap/docker/common/var-lib-docker/overlay2/7b112766bd933afbbcee6547bb7b1b432a46c0cd0fdba70c8d0dab6a5ff24949/diff:/var/snap/docker/common/var-lib-docker/overlay2/5257ff29269f9efb34815951d106ea8a3975b9df2b2bca187e45d967b72ff7c8/diff",
            "MergedDir": "/var/snap/docker/common/var-lib-docker/overlay2/516ce7231a8a8bc552d4be70e8e80af8ed050a34237a45f6522262a82457facb/merged",
            "UpperDir": "/var/snap/docker/common/var-lib-docker/overlay2/516ce7231a8a8bc552d4be70e8e80af8ed050a34237a45f6522262a82457facb/diff",
            "WorkDir": "/var/snap/docker/common/var-lib-docker/overlay2/516ce7231a8a8bc552d4be70e8e80af8ed050a34237a45f6522262a82457facb/work"
        },
        "Name": "overlay2"
    },
    "HostConfig": {
        "AutoRemove": false,
        "Binds": [
            "caddy_data:/usr/share/caddy",
            "caddy_data:/data",
            "caddy_config:/config"
        ],
        "BlkioDeviceReadBps": null,
        "BlkioDeviceReadIOps": null,
        "BlkioDeviceWriteBps": null,
        "BlkioDeviceWriteIOps": null,
        "BlkioWeight": 0,
        "BlkioWeightDevice": [],
        "CapAdd": [
            "AUDIT_WRITE",
            "CHOWN",
            "DAC_OVERRIDE",
            "FOWNER",
            "FSETID",
            "KILL",
            "MKNOD",
            "NET_BIND_SERVICE",
            "NET_RAW",
            "SETFCAP",
            "SETGID",
            "SETPCAP",
            "SETUID",
            "SYS_CHROOT"
        ],
        "CapDrop": [
            "AUDIT_CONTROL",
            "BLOCK_SUSPEND",
            "DAC_READ_SEARCH",
            "IPC_LOCK",
            "IPC_OWNER",
            "LEASE",
            "LINUX_IMMUTABLE",
            "MAC_ADMIN",
            "MAC_OVERRIDE",
            "NET_ADMIN",
            "NET_BROADCAST",
            "SYSLOG",
            "SYS_ADMIN",
            "SYS_BOOT",
            "SYS_MODULE",
            "SYS_NICE",
            "SYS_PACCT",
            "SYS_PTRACE",
            "SYS_RAWIO",
            "SYS_RESOURCE",
            "SYS_TIME",
            "SYS_TTY_CONFIG",
            "WAKE_ALARM"
        ],
        "Cgroup": "",
        "CgroupParent": "",
        "CgroupnsMode": "host",
        "ConsoleSize": [
            0,
            0
        ],
        "ContainerIDFile": "",
        "CpuCount": 0,
        "CpuPercent": 0,
        "CpuPeriod": 0,
        "CpuQuota": 0,
        "CpuRealtimePeriod": 0,
        "CpuRealtimeRuntime": 0,
        "CpuShares": 0,
        "CpusetCpus": "",
        "CpusetMems": "",
        "DeviceCgroupRules": null,
        "DeviceRequests": null,
        "Devices": [],
        "Dns": [],
        "DnsOptions": [],
        "DnsSearch": [],
        "ExtraHosts": null,
        "GroupAdd": null,
        "IOMaximumBandwidth": 0,
        "IOMaximumIOps": 0,
        "IpcMode": "private",
        "Isolation": "",
        "KernelMemory": 0,
        "KernelMemoryTCP": 0,
        "Links": null,
        "LogConfig": {
            "Config": {},
            "Type": "json-file"
        },
        "MaskedPaths": [
            "/proc/asound",
            "/proc/acpi",
            "/proc/kcore",
            "/proc/keys",
            "/proc/latency_stats",
            "/proc/timer_list",
            "/proc/timer_stats",
            "/proc/sched_debug",
            "/proc/scsi",
            "/sys/firmware"
        ],
        "Memory": 0,
        "MemoryReservation": 0,
        "MemorySwap": 0,
        "MemorySwappiness": null,
        "NanoCpus": 0,
        "NetworkMode": "bridge",
        "OomKillDisable": false,
        "OomScoreAdj": 0,
        "PidMode": "",
        "PidsLimit": null,
        "PortBindings": {
            "443/tcp": [
                {
                    "HostIp": "",
                    "HostPort": "443"
                }
            ],
            "80/tcp": [
                {
                    "HostIp": "",
                    "HostPort": "80"
                }
            ]
        },
        "Privileged": false,
        "PublishAllPorts": false,
        "ReadonlyPaths": [
            "/proc/bus",
            "/proc/fs",
            "/proc/irq",
            "/proc/sys",
            "/proc/sysrq-trigger"
        ],
        "ReadonlyRootfs": false,
        "RestartPolicy": {
            "MaximumRetryCount": 0,
            "Name": "always"
        },
        "Runtime": "runc",
        "SecurityOpt": null,
        "ShmSize": 67108864,
        "UTSMode": "",
        "Ulimits": null,
        "UsernsMode": "",
        "VolumeDriver": "",
        "VolumesFrom": null
    },
    "HostnamePath": "/var/snap/docker/common/var-lib-docker/containers/9cb7ce0f22af63709a2a78c20b0a53ba539259bfa3b97aba21a468368bc759a0/hostname",
    "HostsPath": "/var/snap/docker/common/var-lib-docker/containers/9cb7ce0f22af63709a2a78c20b0a53ba539259bfa3b97aba21a468368bc759a0/hosts",
    "Id": "9cb7ce0f22af63709a2a78c20b0a53ba539259bfa3b97aba21a468368bc759a0",
    "Image": "sha256:e50a821fafa344e09dc30d1150bb619f0522186943dfbfe5d01634635c4e11c4",
    "LogPath": "/var/snap/docker/common/var-lib-docker/containers/9cb7ce0f22af63709a2a78c20b0a53ba539259bfa3b97aba21a468368bc759a0/9cb7ce0f22af63709a2a78c20b0a53ba539259bfa3b97aba21a468368bc759a0-json.log",
    "MountLabel": "",
    "Mounts": [
        {
            "Destination": "/usr/share/caddy",
            "Driver": "local",
            "Mode": "z",
            "Name": "caddy_data",
            "Propagation": "",
            "RW": true,
            "Source": "/var/snap/docker/common/var-lib-docker/volumes/caddy_data/_data",
            "Type": "volume"
        },
        {
            "Destination": "/data",
            "Driver": "local",
            "Mode": "z",
            "Name": "caddy_data",
            "Propagation": "",
            "RW": true,
            "Source": "/var/snap/docker/common/var-lib-docker/volumes/caddy_data/_data",
            "Type": "volume"
        },
        {
            "Destination": "/config",
            "Driver": "local",
            "Mode": "z",
            "Name": "caddy_config",
            "Propagation": "",
            "RW": true,
            "Source": "/var/snap/docker/common/var-lib-docker/volumes/caddy_config/_data",
            "Type": "volume"
        }
    ],
    "Name": "/brave_lamport",
    "NetworkSettings": {
        "Bridge": "",
        "EndpointID": "99fe79eb86bf27ba94391ef2120929a0a5b34945e29699a6b83590e0fa99871b",
        "Gateway": "172.17.0.1",
        "GlobalIPv6Address": "",
        "GlobalIPv6PrefixLen": 0,
        "HairpinMode": false,
        "IPAddress": "172.17.0.7",
        "IPPrefixLen": 16,
        "IPv6Gateway": "",
        "LinkLocalIPv6Address": "",
        "LinkLocalIPv6PrefixLen": 0,
        "MacAddress": "02:42:ac:11:00:07",
        "Networks": {
            "bridge": {
                "Aliases": null,
                "DriverOpts": null,
                "EndpointID": "99fe79eb86bf27ba94391ef2120929a0a5b34945e29699a6b83590e0fa99871b",
                "Gateway": "172.17.0.1",
                "GlobalIPv6Address": "",
                "GlobalIPv6PrefixLen": 0,
                "IPAMConfig": {},
                "IPAddress": "172.17.0.7",
                "IPPrefixLen": 16,
                "IPv6Gateway": "",
                "Links": null,
                "MacAddress": "02:42:ac:11:00:07",
                "NetworkID": "3730cae6f8f529d49ea3987c1c934dbe8ca778b96ca5660a383a34f3f8442f99"
            }
        },
        "Ports": {
            "2019/tcp": null,
            "443/tcp": [
                {
                    "HostIp": "0.0.0.0",
                    "HostPort": "443"
                },
                {
                    "HostIp": "::",
                    "HostPort": "443"
                }
            ],
            "80/tcp": [
                {
                    "HostIp": "0.0.0.0",
                    "HostPort": "80"
                },
                {
                    "HostIp": "::",
                    "HostPort": "80"
                }
            ]
        },
        "SandboxID": "3e6aa9a67cf27891796353c7b10ecc28afab9f9fddce0c9b9be637505c62571d",
        "SandboxKey": "/run/snap.docker/netns/3e6aa9a67cf2",
        "SecondaryIPAddresses": null,
        "SecondaryIPv6Addresses": null
    },
    "Path": "caddy",
    "Platform": "linux",
    "Portainer": {
        "ResourceControl": {
            "Id": 9,
            "ResourceId": "9cb7ce0f22af63709a2a78c20b0a53ba539259bfa3b97aba21a468368bc759a0",
            "SubResourceIds": [],
            "Type": 1,
            "UserAccesses": [],
            "TeamAccesses": [],
            "Public": false,
            "AdministratorsOnly": true,
            "System": false
        }
    },
    "ProcessLabel": "",
    "ResolvConfPath": "/var/snap/docker/common/var-lib-docker/containers/9cb7ce0f22af63709a2a78c20b0a53ba539259bfa3b97aba21a468368bc759a0/resolv.conf",
    "RestartCount": 0,
    "State": {
        "Dead": false,
        "Error": "",
        "ExitCode": 0,
        "FinishedAt": "2021-09-22T16:56:00.579465106Z",
        "OOMKilled": false,
        "Paused": false,
        "Pid": 3180016,
        "Restarting": false,
        "Running": true,
        "StartedAt": "2021-09-23T14:26:44.37184747Z",
        "Status": "running"
    }
}

Now, if i type caddy into a ssh session i get

~$ caddy
caddy: command not found

If i install caddy on the system via ‘sudo apt install caddy’, then i am able to see the landing page. In docker, that page is not accessible.

i’m tying to access my media server from home outside the network.

I can’t make head or tails of caddyfile. it doesn’t make sense to me.

The ‘-v /site:/usr/share/caddy’ didnt work. I kept getting

docker: Error response from daemon: error while creating mount source path '/site': mkdir /site: read-only file system.

So i moved the location to the same one as /data.

SO while running the container and accessing the’https://jfhomeserver.hopto.org/web/index.html’, i get lines in the log.

{"level":"info","ts":1632407204.6120787,"logger":"tls","msg":"finished cleaning storage units"}
Caddy proxying https://jfhomeserver.hopto.org -> http://192.168.1.130:8096
{"level":"info","ts":1632407204.6205094,"msg":"autosaved config (load with --resume flag)","file":"/config/caddy/autosave.json"}
{"level":"info","ts":1632407751.1804733,"msg":"shutting down apps, then terminating","signal":"SIGTERM"}
{"level":"warn","ts":1632407751.1805358,"msg":"exiting; byeee!! 👋","signal":"SIGTERM"}
{"level":"info","ts":1632407751.1840951,"logger":"tls.cache.maintenance","msg":"stopped background certificate maintenance","cache":"0xc000278930"}
{"level":"info","ts":1632407751.1842082,"msg":"shutdown complete","signal":"SIGTERM","exit_code":0}
{"level":"warn","ts":1632407986.2877548,"logger":"admin","msg":"admin endpoint disabled"}
{"level":"info","ts":1632407986.2880635,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc000363f10"}
{"level":"info","ts":1632407986.2881923,"logger":"http","msg":"server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS","server_name":"proxy","https_port":443}
{"level":"info","ts":1632407986.2883427,"logger":"http","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"proxy"}
{"level":"info","ts":1632407986.2889175,"logger":"tls","msg":"cleaning storage unit","description":"FileStorage:/data/caddy"}
{"level":"info","ts":1632407986.290976,"logger":"http","msg":"enabling automatic TLS certificate management","domains":["jfhomeserver.hopto.org"]}
{"level":"info","ts":1632407986.2922342,"logger":"tls","msg":"finished cleaning storage units"}
Caddy proxying https://jfhomeserver.hopto.org -> http://192.168.1.130:8096
{"level":"info","ts":1632407986.292604,"msg":"autosaved config (load with --resume flag)","file":"/config/caddy/autosave.json"}
{"level":"info","ts":1632408196.9164124,"msg":"shutting down apps, then terminating","signal":"SIGTERM"}
{"level":"warn","ts":1632408196.9164906,"msg":"exiting; byeee!! 👋","signal":"SIGTERM"}
{"level":"info","ts":1632408196.9201043,"logger":"tls.cache.maintenance","msg":"stopped background certificate maintenance","cache":"0xc000363f10"}
{"level":"info","ts":1632408196.9201894,"msg":"shutdown complete","signal":"SIGTERM","exit_code":0}
{"level":"warn","ts":1632408197.624354,"logger":"admin","msg":"admin endpoint disabled"}
{"level":"info","ts":1632408197.624595,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc0002e5810"}
{"level":"info","ts":1632408197.6246216,"logger":"http","msg":"server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS","server_name":"proxy","https_port":443}
{"level":"info","ts":1632408197.6246362,"logger":"http","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"proxy"}
{"level":"info","ts":1632408197.624996,"logger":"tls","msg":"cleaning storage unit","description":"FileStorage:/data/caddy"}
{"level":"info","ts":1632408197.6254182,"logger":"http","msg":"enabling automatic TLS certificate management","domains":["jfhomeserver.hopto.org"]}
{"level":"info","ts":1632408197.6256447,"logger":"tls","msg":"finished cleaning storage units"}
Caddy proxying https://jfhomeserver.hopto.org -> http://192.168.1.130:8096
{"level":"info","ts":1632408197.6291306,"msg":"autosaved config (load with --resume flag)","file":"/config/caddy/autosave.json"}

I hope i’ve given enough information to help resolve this issue.

Thank you.

Okay, that looks better - that was missing from your previous posts :+1:

Don’t use multiple volumes for caddy_data. Remove the first one there. If you’re proxying, you don’t need to touch /usr/share/caddy.

I don’t understand what you’re doing here. Are you running that on the host machine? If you’re running Caddy in docker, then of course you won’t have a caddy program you can run directly on the host machine, because it’s running in Docker.

Oh - only choose one or the other, don’t do both. If you’re inexperienced with Docker, it’ll definitely be easier to use the systemd service (which comes with the apt package).

Okay - is that media server running on another machine, or on the same machine? If on the same machine, is it Dockerized? I assume from the port number 8096 that it’s Jellyfin?

Have you read the Getting Started guide?

For a simple reverse proxy, your Caddyfile would just be this:

jfhomeserver.hopto.org {
	reverse_proxy 192.168.1.130:8096
}

Yeah as I said earlier – don’t do that, just remove that volume. It’s not useful here if you’re proxying.

If you prefer to use Docker, then I recommend using docker-compose. It’s easier to manage than running the docker run commands by hand.

From that docker-compose.yml, you won’t need the - $PWD/site:/srv volume. Make a Caddyfile beside the docker-compose.yml, then run docker-compose up -d and Caddy will run.

If you are using Docker, make sure to uninstall the Caddy apt package, so it doesn’t conflict (only one program can bind to ports 80 and 443 at a time).

1 Like

I have amended the container :slight_smile:

I thought the usage guide would be the same regardless of the install method. So i would always have to use a caddyfile while using docker?

I’m only using docker. I tried the apt way and it’s more fiddly than i’d like. I prefer to use the docker since i can start again from scratch without any issues on the host system.

The server is a different machine that i ssh into.

Yes, jellyfin is also running on the same machine as caddy and is dockerized. It’s also connected via bridge.

Yes, a few times. There seems to be several steps missing or it assumes a familiarity with the process, and is not suitable for someone like me who is a newbie at this.

For example ‘Save this to a JSON file’, save it where? on my machine or on the machine i’m ssh’d into? what folder etc. plus a lot of the commands, i.e caddy, won’t run from terminal. There doesn’t seem to be a usage guide for a docker container.

I’m using portainer atm, it’s just easier using a gui for me.

I only try one while disabling the other. At the moment, i’ve removed the apt package and running docker only.

Here is my current config

{
    "AppArmorProfile": "docker-default",
    "Args": [
        "reverse-proxy",
        "--from",
        "jfhomeserver.hopto.org",
        "--to",
        "192.168.1.130:8096"
    ],
    "Config": {
        "AttachStderr": false,
        "AttachStdin": false,
        "AttachStdout": false,
        "Cmd": [
            "caddy",
            "reverse-proxy",
            "--from",
            "jfhomeserver.hopto.org",
            "--to",
            "192.168.1.130:8096"
        ],
        "Domainname": "",
        "Entrypoint": null,
        "Env": [
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
            "CADDY_VERSION=v2.4.5",
            "XDG_CONFIG_HOME=/config",
            "XDG_DATA_HOME=/data",
            "TZ=Etc/UTC"
        ],
        "ExposedPorts": {
            "2019/tcp": {},
            "443/tcp": {},
            "80/tcp": {}
        },
        "Hostname": "d406cdc88ce0",
        "Image": "caddy:latest",
        "Labels": {
            "org.opencontainers.image.description": "a powerful, enterprise-ready, open source web server with automatic HTTPS written in Go",
            "org.opencontainers.image.documentation": "https://caddyserver.com/docs",
            "org.opencontainers.image.licenses": "Apache-2.0",
            "org.opencontainers.image.source": "https://github.com/caddyserver/caddy-docker",
            "org.opencontainers.image.title": "Caddy",
            "org.opencontainers.image.url": "https://caddyserver.com",
            "org.opencontainers.image.vendor": "Light Code Labs",
            "org.opencontainers.image.version": "v2.4.5"
        },
        "OnBuild": null,
        "OpenStdin": false,
        "StdinOnce": false,
        "Tty": false,
        "User": "",
        "Volumes": {
            "/config": {},
            "/data": {}
        },
        "WorkingDir": "/srv"
    },
    "Created": "2021-09-23T15:37:25.193896085Z",
    "Driver": "overlay2",
    "ExecIDs": null,
    "GraphDriver": {
        "Data": {
            "LowerDir": "/var/snap/docker/common/var-lib-docker/overlay2/30c01e22f82bcaea8ceedcc09d948fc5525811622cd369319f5b9ad7bf77cb67-init/diff:/var/snap/docker/common/var-lib-docker/overlay2/80eaf6af734e840f1d125a133e4d75fe706f7dcb071f8066e29e26e01efb2732/diff:/var/snap/docker/common/var-lib-docker/overlay2/34f2947c854b2f7f13d84428195b14c9e241887711277c46c0892f1f0e4a55e5/diff:/var/snap/docker/common/var-lib-docker/overlay2/2f7a0276567bd236af30574dc38b44b79d0708bb609982639b9552feee36a9b7/diff:/var/snap/docker/common/var-lib-docker/overlay2/7b112766bd933afbbcee6547bb7b1b432a46c0cd0fdba70c8d0dab6a5ff24949/diff:/var/snap/docker/common/var-lib-docker/overlay2/5257ff29269f9efb34815951d106ea8a3975b9df2b2bca187e45d967b72ff7c8/diff",
            "MergedDir": "/var/snap/docker/common/var-lib-docker/overlay2/30c01e22f82bcaea8ceedcc09d948fc5525811622cd369319f5b9ad7bf77cb67/merged",
            "UpperDir": "/var/snap/docker/common/var-lib-docker/overlay2/30c01e22f82bcaea8ceedcc09d948fc5525811622cd369319f5b9ad7bf77cb67/diff",
            "WorkDir": "/var/snap/docker/common/var-lib-docker/overlay2/30c01e22f82bcaea8ceedcc09d948fc5525811622cd369319f5b9ad7bf77cb67/work"
        },
        "Name": "overlay2"
    },
    "HostConfig": {
        "AutoRemove": false,
        "Binds": [
            "caddy_data:/data",
            "caddy_config:/config"
        ],
        "BlkioDeviceReadBps": null,
        "BlkioDeviceReadIOps": null,
        "BlkioDeviceWriteBps": null,
        "BlkioDeviceWriteIOps": null,
        "BlkioWeight": 0,
        "BlkioWeightDevice": [],
        "CapAdd": [
            "AUDIT_WRITE",
            "CHOWN",
            "DAC_OVERRIDE",
            "FOWNER",
            "FSETID",
            "KILL",
            "MKNOD",
            "NET_BIND_SERVICE",
            "NET_RAW",
            "SETFCAP",
            "SETGID",
            "SETPCAP",
            "SETUID",
            "SYS_CHROOT"
        ],
        "CapDrop": [
            "AUDIT_CONTROL",
            "BLOCK_SUSPEND",
            "DAC_READ_SEARCH",
            "IPC_LOCK",
            "IPC_OWNER",
            "LEASE",
            "LINUX_IMMUTABLE",
            "MAC_ADMIN",
            "MAC_OVERRIDE",
            "NET_ADMIN",
            "NET_BROADCAST",
            "SYSLOG",
            "SYS_ADMIN",
            "SYS_BOOT",
            "SYS_MODULE",
            "SYS_NICE",
            "SYS_PACCT",
            "SYS_PTRACE",
            "SYS_RAWIO",
            "SYS_RESOURCE",
            "SYS_TIME",
            "SYS_TTY_CONFIG",
            "WAKE_ALARM"
        ],
        "Cgroup": "",
        "CgroupParent": "",
        "CgroupnsMode": "host",
        "ConsoleSize": [
            0,
            0
        ],
        "ContainerIDFile": "",
        "CpuCount": 0,
        "CpuPercent": 0,
        "CpuPeriod": 0,
        "CpuQuota": 0,
        "CpuRealtimePeriod": 0,
        "CpuRealtimeRuntime": 0,
        "CpuShares": 0,
        "CpusetCpus": "",
        "CpusetMems": "",
        "DeviceCgroupRules": null,
        "DeviceRequests": null,
        "Devices": [],
        "Dns": [],
        "DnsOptions": [],
        "DnsSearch": [],
        "ExtraHosts": null,
        "GroupAdd": null,
        "IOMaximumBandwidth": 0,
        "IOMaximumIOps": 0,
        "IpcMode": "private",
        "Isolation": "",
        "KernelMemory": 0,
        "KernelMemoryTCP": 0,
        "Links": null,
        "LogConfig": {
            "Config": {},
            "Type": "json-file"
        },
        "MaskedPaths": [
            "/proc/asound",
            "/proc/acpi",
            "/proc/kcore",
            "/proc/keys",
            "/proc/latency_stats",
            "/proc/timer_list",
            "/proc/timer_stats",
            "/proc/sched_debug",
            "/proc/scsi",
            "/sys/firmware"
        ],
        "Memory": 0,
        "MemoryReservation": 0,
        "MemorySwap": 0,
        "MemorySwappiness": null,
        "NanoCpus": 0,
        "NetworkMode": "bridge",
        "OomKillDisable": false,
        "OomScoreAdj": 0,
        "PidMode": "",
        "PidsLimit": null,
        "PortBindings": {
            "443/tcp": [
                {
                    "HostIp": "",
                    "HostPort": "443"
                }
            ],
            "80/tcp": [
                {
                    "HostIp": "",
                    "HostPort": "80"
                }
            ]
        },
        "Privileged": false,
        "PublishAllPorts": false,
        "ReadonlyPaths": [
            "/proc/bus",
            "/proc/fs",
            "/proc/irq",
            "/proc/sys",
            "/proc/sysrq-trigger"
        ],
        "ReadonlyRootfs": false,
        "RestartPolicy": {
            "MaximumRetryCount": 0,
            "Name": "always"
        },
        "Runtime": "runc",
        "SecurityOpt": null,
        "ShmSize": 67108864,
        "UTSMode": "",
        "Ulimits": null,
        "UsernsMode": "",
        "VolumeDriver": "",
        "VolumesFrom": null
    },
    "HostnamePath": "/var/snap/docker/common/var-lib-docker/containers/13ff793c1be08e5365e888b69f428eb06fcbac0a97979706532dd9432b6b4914/hostname",
    "HostsPath": "/var/snap/docker/common/var-lib-docker/containers/13ff793c1be08e5365e888b69f428eb06fcbac0a97979706532dd9432b6b4914/hosts",
    "Id": "13ff793c1be08e5365e888b69f428eb06fcbac0a97979706532dd9432b6b4914",
    "Image": "sha256:e50a821fafa344e09dc30d1150bb619f0522186943dfbfe5d01634635c4e11c4",
    "LogPath": "/var/snap/docker/common/var-lib-docker/containers/13ff793c1be08e5365e888b69f428eb06fcbac0a97979706532dd9432b6b4914/13ff793c1be08e5365e888b69f428eb06fcbac0a97979706532dd9432b6b4914-json.log",
    "MountLabel": "",
    "Mounts": [
        {
            "Destination": "/data",
            "Driver": "local",
            "Mode": "z",
            "Name": "caddy_data",
            "Propagation": "",
            "RW": true,
            "Source": "/var/snap/docker/common/var-lib-docker/volumes/caddy_data/_data",
            "Type": "volume"
        },
        {
            "Destination": "/config",
            "Driver": "local",
            "Mode": "z",
            "Name": "caddy_config",
            "Propagation": "",
            "RW": true,
            "Source": "/var/snap/docker/common/var-lib-docker/volumes/caddy_config/_data",
            "Type": "volume"
        }
    ],
    "Name": "/caddy",
    "NetworkSettings": {
        "Bridge": "",
        "EndpointID": "",
        "Gateway": "",
        "GlobalIPv6Address": "",
        "GlobalIPv6PrefixLen": 0,
        "HairpinMode": false,
        "IPAddress": "",
        "IPPrefixLen": 0,
        "IPv6Gateway": "",
        "LinkLocalIPv6Address": "",
        "LinkLocalIPv6PrefixLen": 0,
        "MacAddress": "",
        "Networks": {
            "bridge": {
                "Aliases": null,
                "DriverOpts": null,
                "EndpointID": "",
                "Gateway": "",
                "GlobalIPv6Address": "",
                "GlobalIPv6PrefixLen": 0,
                "IPAMConfig": {},
                "IPAddress": "",
                "IPPrefixLen": 0,
                "IPv6Gateway": "",
                "Links": null,
                "MacAddress": "",
                "NetworkID": "3730cae6f8f529d49ea3987c1c934dbe8ca778b96ca5660a383a34f3f8442f99"
            }
        },
        "Ports": {},
        "SandboxID": "70a1c789a09f52950877d0e6f63d7dfe897989e9aa7f54f4aec66990f46a5ccc",
        "SandboxKey": "/run/snap.docker/netns/70a1c789a09f",
        "SecondaryIPAddresses": null,
        "SecondaryIPv6Addresses": null
    },
    "Path": "caddy",
    "Platform": "linux",
    "Portainer": {
        "ResourceControl": {
            "Id": 13,
            "ResourceId": "13ff793c1be08e5365e888b69f428eb06fcbac0a97979706532dd9432b6b4914",
            "SubResourceIds": [],
            "Type": 1,
            "UserAccesses": [],
            "TeamAccesses": [],
            "Public": false,
            "AdministratorsOnly": true,
            "System": false
        }
    },
    "ProcessLabel": "",
    "ResolvConfPath": "/var/snap/docker/common/var-lib-docker/containers/13ff793c1be08e5365e888b69f428eb06fcbac0a97979706532dd9432b6b4914/resolv.conf",
    "RestartCount": 0,
    "State": {
        "Dead": false,
        "Error": "",
        "ExitCode": 0,
        "FinishedAt": "2021-09-23T17:22:11.609879049Z",
        "OOMKilled": false,
        "Paused": false,
        "Pid": 0,
        "Restarting": false,
        "Running": false,
        "StartedAt": "2021-09-23T15:37:27.461075377Z",
        "Status": "exited"
    }
}

Last few logs


{"level":"info","ts":1632491311.570003,"logger":"http","msg":"server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS","server_name":"proxy","https_port":443}


{"level":"info","ts":1632491311.57014,"logger":"http","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"proxy"}


{"level":"info","ts":1632491311.5745246,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc00037cee0"}


{"level":"info","ts":1632491311.5787182,"logger":"http","msg":"enabling automatic TLS certificate management","domains":["jfhomeserver.hopto.org"]}


{"level":"info","ts":1632491311.5856566,"msg":"autosaved config (load with --resume flag)","file":"/config/caddy/autosave.json"}


Caddy proxying https://jfhomeserver.hopto.org -> http://192.168.1.130:8096


{"level":"info","ts":1632491311.5860617,"logger":"tls","msg":"cleaning storage unit","description":"FileStorage:/data/caddy"}

and the website, https://jfhomeserver.hopto.org/, can't provide a secure connection.

I strongly recommend using a Caddyfile.

Like I said earlier, the caddy reverse-proxy command is meant as a quick-and-easy way to spin up a server for developers on their own laptops and such, something they only spin up for a few hours while doing some development work. It’s not ideal to use it for long-term use, because it has a very narrow usecase.

The Getting Started guide points it out because it’s just nice to know about it in case that’s what you’re looking to use it for. But in Docker, it’s best to use config files, it gives you more “room to grow” your usage of Caddy. If you want to proxy a second domain to another service, you have to use a config file, because the command doesn’t offer that.

Okay, if they’re both dockerized, I strongly recommend putting both Caddy and Jellyfin in one docker-compose.yml file. It’ll simplify the networking between Caddy and Jellyfin. By default, services in the same docker-compose file use the same Docker network, so they can talk to eachother no problem. If you run them separately, then they wouldn’t use the same network (by default, unless you specify the network to use in the docker run command) which complicates things – you’d have to proxy to the host machine’s IP address (i.e. the Docker host IP) and that’s kinda brittle. Instead, with them in the same network, you would just do reverse_proxy jellyfin:8096 and it would just work.

Yeah, the Getting Started guide is not written with Docker in mind. Running things in Docker is fundamentally different than having it installed directly on the machine, because you don’t tend to directly interact with the command-line interface. It puts the program on its own little isolated island.

I think you’re talking about this part about the JSON config – this assumes you have Caddy running on the host machine, the same machine on which you have a terminal session; then you’d make a file called caddy.json with a terminal text editor like vi or nano (in your currently working directory, doesn’t matter where, really, you can rm to delete it afterwards), then run the curl command that follows to load that config into Caddy.

This example is to show how Caddy works under the hood. Caddy’s underlying config language is JSON. The Caddyfile is a “config adapter”, its job is to generate a valid JSON config to load into Caddy. It’s there to simplify using Caddy, because directly using JSON is not so user-friendly, but the Caddyfile is much easier to reason about.

This page in the docs explains the structure of the Caddyfile:

Okay – that wasn’t clear either from the previous posts. I don’t use portainer. Does it run things in a single Docker network? If so, you can just use the jellyfin container name to proxy to it. Better than using an IP address.

Those logs just look like Caddy’s usual startup. Nothing stands out.

Are you trying to connect to https://jfhomeserver.hopto.org/ from inside the same network? Try with your cellphone on your cellular network (or any machine not inside your LAN).

If that works, then the issue is that your router doesn’t support Hairpin NAT (see Hairpinning - Wikipedia) so it doesn’t know how to route requests to the WAN IP address of your own network – i.e. TCP packets reach your router, and it doesn’t know what to do with it so it drops it on the floor. The typical way to solve this is by running a DNS server in your local network that makes that domain resolve to the LAN IP instead (probably 192.168.1.<something>), and any device outside your LAN will still resolve to the WAN IP address.

But again, I’m still making assumptions here, because I don’t have the full picture of your setup.

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