Lb_policy ip_hash fails

1. My Caddy version (caddy version):

v2.0.0-beta.20 h1:oUNG1uh0UV8LWLlAVDZolFzk112++V/pxY+fF0HLmlY=

2. How I run Caddy:

a. System environment:

I use docker-compose with the latest docker from the Docker CE repository on Debian 10.

c. Service/unit/compose file:

version: '3.7'

services:
  caddy:
    image: caddy/caddy:latest
    restart: unless-stopped
    networks:
      dockernet:
        ipv4_address: 10.0.0.2
        ipv6_address: fd00::2
    volumes:
      - ./caddy/Caddyfile:/etc/caddy/Caddyfile
      - ./caddy/data:/data

networks:
    dockernet:
        external: true

d. My complete Caddyfile or JSON config:

    {
        admin off
    }
    (proxy) {
          header_up X-Real-IP {remote_host}
          header_up X-Forwarded-Proto {scheme}
    }

    example.net, www.example.net {
        reverse_proxy nginx_acb_nginx:8000
        reverse_proxy /_matrix synapse:8008 {
            import proxy
        }
    }

    example.net:8448 {
        reverse_proxy synapse:8008 {
            import proxy
        }
    }

    example.org, www.example.org {
        reverse_proxy nginx_acb_nginx:8001 {
            import proxy
        }
    }

    forum.example.org {
        reverse_proxy forum:4567 forum:4568 {
            import proxy
        }
    }


3. The problem I’m having:

I’m trying to enable the loadbalancing policy “ip_hash” which is found in the docs here.

4. Error messages and/or full log output:

{"level":"info","ts":1586120838.0300763,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":"caddyfile"}

run: adapting config using caddyfile: parsing caddyfile tokens for 'reverse_proxy': /etc/caddy/Caddyfile:32 - Error during parsing: load balancing policy module 'http.reverse_proxy.selection_policies.ip_hash' is not a Caddyfile unmarshaler

{"level":"info","ts":1586120839.3675978,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":"caddyfile"}

run: adapting config using caddyfile: parsing caddyfile tokens for 'reverse_proxy': /etc/caddy/Caddyfile:32 - Error during parsing: load balancing policy module 'http.reverse_proxy.selection_policies.ip_hash' is not a Caddyfile unmarshaler
1 Like

You’re right, the functions to unmarshal the Caddyfile for LB policies were missing!

I made a PR to fix it:

https://github.com/caddyserver/caddy/pull/3230

You can try the build artifacts here (you can replace the caddy binary in your docker container with a volume, temporarily):

https://github.com/caddyserver/caddy/actions/runs/71366383

3 Likes

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