Caddy reverse_proxy parsing errors in docker container

1. The problem I’m having:

I’m trying to add additional reverse proxies (actually handle_path but this is a simple example). The following Caddyfile works fine:

localhost:8443 {
	reverse_proxy reveal-vault:8200
	reverse_proxy /whoami whoami:80
}

but once I add another reverse_proxy (see below), caddy complains about an unexpected token r. Now if I run

docker exec -it reveal-caddy caddy fmt --overwrite /etc/caddy/Caddyfile

It returns:

localhost:8443 {
	reverse_proxy reveal-vault:8200
	reverse_proxy /whoami whoami:80
	r

2. Error messages and/or full log output:

Error: adapting config using caddyfile: syntax error: unexpected token 'r', expecting '}', at /etc/caddy/Caddyfile:4 import chain: ['']

3. Caddy version:

v2.7.6 h1:w0NymbG2m9PcvKWsrXO6EEkY9Ru4FJK8uQbYcev1p3A=

4. How I installed and ran Caddy:

a. System environment:

b. Command:

docker exec -it reveal-caddy caddy reload -c /etc/caddy/Caddyfile

c. Service/unit/compose file:

services:
  caddy:
    image: caddy:latest
    container_name: reveal-caddy
    cap_add:
      - NET_ADMIN
    ports:
      - "8443:8443"
      - "8443:8443/udp"
    networks:
      - frontend
      - backend
    volumes:
      - caddy-data:/data/
      - ./caddy/Caddyfile:/etc/caddy/Caddyfile
    restart: always

d. My complete Caddy config:

localhost:8443 {
	reverse_proxy reveal-vault:8200
	reverse_proxy /whoami whoami:80
	reverse_proxy /bob whomami:80
}

5. Links to relevant resources:

Partially answering my own question. It seems the file inside the container is getting mangled.

localhost:8443 {
	reverse_proxy reveal-vault:8200
	reverse_proxy /whoami whoami:80
	r%    

Outside it is correct. If I stop and restart the container, the correct version is seen. I’m running this on MacOS X.

What the heck.

Check that the file’s encoding is correct. Use unix line endings, etc.

I’m so use to running docker on Linux I forget that MacOS is not the same. In this case, it seems from the MacOS Host side, the file is a fix byte size. Anything I wrote longer than that got truncated (which explains why I sometimes saw EOF). While changes in the container are mirrored on the Host side.

That’s… insane.

I’m sorry you have to use a Mac. Docker on Mac is a disaster. :frowning:

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