websocketconsulenvoyproxysidecar

Does consul sidecars support websockets upstream?


Is it possible to configure a consul agent sidecar with a websocket upstream? I have tried the following configuration but it doesn't work:

{
  "bind_addr": "172.17.0.2",
  "data_dir": "/consul/data",
  "datacenter": "dc1",
  "node_id" : "98dc3bf4-a364-46d9-8b72-624963064ab2",
  "node_name": "socket-client-agent",
  "leave_on_terminate": true,
  "ports": [
    {
      "grpc": 8502
    }
   ],
  "server": false,
  "service": [
  {
   "address": "172.17.0.3",
   "connect": [
     {
       "sidecar_service": [
         {
           "checks": [
             {
               "interval": "10s",
               "name": "socket-client-sidecar-proxy",
               "tcp": "172.17.0.3:21000"
             }
           ],
          "port": 21000,
          "proxy": [
            {
              "config": [
                {
                  "bind_address": "0.0.0.0",
                  "bind_port": 21000,
                  "protocol": "tcp"
                }
              ],
              "upstreams": [
                {
                  "destination_name": "sockets-server",
                  "local_bind_port": 5001,
                  "config": {
                    "protocol": "tcp"
                  }
                }
              ]
            }
          ]
        }
      ]
    }
   ],
   "id": "socket-client-0",
   "name": "socket-client",
   "port": 5000
   }
   ],
   "ui_config": [
   {
     "enabled": false
   }
  ]
}

From the configuration I'm trying to connect to sockets-server service which uses websockets protocol. I'm using envoy as sidecar proxy.


Solution

  • Currently Consul does not configure Envoy correctly to support WebSocket upgrades. This GitHub issue has more detail on the issue, and potential fix – https://github.com/hashicorp/consul/issues/9473.