mholt/caddy-l4

Proxying Redis

mbuckbee opened this issue · 2 comments

I was experimenting with proxying Redis connections for an app that I run. I have an existing HA Proxy setup that works and attempted to port the config over to L4 as I'm using Caddy already for HTTP and it would be fantastic to have all this in a single app.

For reference here is the HA Proxy config:

defaults REDIS
 mode tcp
 timeout connect  4s
 timeout server  30s
 timeout client  30s
frontend ft_redis
 bind 0.0.0.0:6379 name redisv4
 bind :::6379 name redisv6
 default_backend bk_redis
backend bk_redis
 timeout client 360s
 timeout server 360s
 server upstash_redis INTERNAL_REDIS_HOST:6379 check inter 1s

and here is my L4 config

{
  "logging": {
    "logs": {
      "default": {
        "level": "DEBUG"
      }
    }
  },
	"apps": {
    "layer4": {
      "servers": {
        "redis": {
          "listen": ["0.0.0.0:6379"],
          "routes": [
            {
              "handle": [
                {
                  "handler": "proxy",     
                  "proxy_protocol": "v1",             
                  "upstreams": [
                    {"dial": ["INTERNAL-REDIS-HOST:6379"]}
                  ]
                }
              ]
            }
          ]
        }
      }
    }
	}
}

This was being deployed to Fly.io, and I'm not sure if I was botching up the handler or proxy config. Any help is appreciated.

Are you sure redis supports proxy protocol? Remove that if you're not sure.