haproxytech / dataplaneapi

HAProxy Data Plane API
https://www.haproxy.com/documentation/dataplaneapi/
Apache License 2.0
328 stars 76 forks source link

Bind frontend to a unix socket #326

Closed deric closed 8 months ago

deric commented 8 months ago

I'm trying to add a new frontend and I'd like to bind it to a Unix socket. The haproxy.cfg should look like this:

frontend web
  mode http
  bind /run/haproxy/web.sock
  use_backend myapp

I'm using an API call like this:

POST /services/haproxy/configuration/frontends?transaction_id=xxx
 {
        "default_backend": "myapp",
        "mode": "http",
        "name": myfrontend,
        "bind_process": "/run/haproxy/web.sock",
    }

Is there another parameter than bind_process that would allow passing Unix socket?

msg="bind-process 'web.sock' is not a valid number/range."

I'm using fairly old version, to match to OS package version:

HAProxy Data Plane API v2.3.9
mjuraga commented 8 months ago

Hi, to add binds to a frontend, you should use the binds resource at

POST /services/haproxy/configuration/binds?frontend=web&transaction_id=xxx 

{
  "name": "my_unix_socket_test_bind",
  "address": "/run/haproxy/web.sock"
}
deric commented 8 months ago

@mjuraga Awesome, works fine, thanks!