caddy2-proxyprotocol icon indicating copy to clipboard operation
caddy2-proxyprotocol copied to clipboard

global option servers ignored

Open Miggets7 opened this issue 2 years ago • 0 comments

Hi all,

I'm trying to use the module with the following Caddyfile:

{
	admin 0.0.0.0:2019
	servers {
		listener_wrappers {
			proxy_protocol {
				timeout 2s
				allow 0.0.0.0/0
			}
			http_redirect
			tls
		}
	}
	storage consul {
		address consul:8500
		timeout 10
		prefix caddytls
		value_prefix caddy
		aes_key consultls-1234567890-caddytls-32
		tls_enabled false
		tls_insecure true
	}
}

I'm using caddy in a docker swarm with the following compose file:

version: "3.7"

services:      
  consul:
    image: consul:1.14
    command: "agent -server -bootstrap -ui -client 0.0.0.0 -bind '{{ GetInterfaceIP \"eth0\"}}'"
    networks:
      - consul
    volumes:
      - consul_data:/consul/data
    deploy:
      replicas: 1
      placement:
        constraints: [node.role==manager]    
        
  consul-replica:
    image: consul:latest
    command: "agent -server -retry-join consul -client 0.0.0.0 -bind '{{ GetInterfaceIP \"eth0\"}}'"
    depends_on:
      - consul
    volumes:
      - consul_replica_data:/consul/data
    networks:
      - consul
    deploy:
      mode: global
      placement:
        preferences:
          - spread: node.id
      
  caddy:
    depends_on:
      - consul
    image: custom_caddy_image
    ports:
      - 2019:2019
      - 80:80
      - 443:443
    environment:
      - CADDY_INGRESS_NETWORKS=caddy-network
      - CONSUL_HTTP_ADDR=consul:8500
    networks:
      - caddy-network
      - consul
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    deploy:
      labels:
        caddy.email: [email protected]
      placement:
        constraints:
          - node.role == manager # I have 3 manager nodes
        preferences:
          - spread: node.id
      replicas: 1

networks:
  caddy-network:
  consul:
    driver: overlay

volumes:

  consul_data: {}
  consul_replica_data: {}

with a custom build:

FROM caddy:2.6-builder-alpine AS builder

RUN xcaddy build \
    --with github.com/pteich/caddy-tlsconsul \
    --with github.com/lucaslorentz/caddy-docker-proxy/v2 \
    --with github.com/mastercactapus/caddy2-proxyprotocol


FROM caddy:2.6-alpine
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
COPY Caddyfile /etc/caddy/Caddyfile
# Install package with certutil
RUN apk add --no-cache nss-tools
CMD ["caddy", "docker-proxy", "--caddyfile-path", "/etc/caddy/Caddyfile"]

But then in the logs I see the final JSON format of the Caddyfile:

{
	"admin": {
		"listen": "0.0.0.0:2019"
	},
	"storage": {
		"ConsulClient": null,
		"Storage": null,
		"address": "consul:8500",
		"aes_key": "Y29uc3VsdGxzLTEyMzQ1Njc4OTAtY2FkZHl0bHMtMzI=",
		"module": "consul",
		"prefix": "caddytls",
		"timeout": 10,
		"tls_enabled": false,
		"tls_insecure": true,
		"token": "",
		"value_prefix": "stofcaddy"
	}
}

So the module isn't used. What's happening here?

Miggets7 avatar Nov 23 '22 13:11 Miggets7