Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

global option servers ignored #14

Open
Miggets7 opened this issue Nov 23, 2022 · 0 comments
Open

global option servers ignored #14

Miggets7 opened this issue Nov 23, 2022 · 0 comments

Comments

@Miggets7
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant