Question

How To Pass arguments to LUA from HAProxy config

How To Pass arguments to LUA from HAProxy config. I am trying to pass certificate DN information for client and CA, but getting error in haproxy config check.

HAProxy LUA config

global
    lua-load /usr/sbin/lua-choose-backend.lua

  frontend http-in
    mode http

    log-format %ci:%cp\ [%t]\ %ft\ %b/%s\ %Tq/%Tw/%Tc/%Tr/%Tt\ %ST\ %B\ %CC\ %CS\ %tsc\ %ac/%fc/%bc/%sc/%rc\ %sq/%bq\ %hr\ %hs\ {%[ssl_c_verify],%{+Q}[ssl_c_s_dn],%{+Q}[ssl_c_i_dn]}\ %{+Q}r


    bind *:443 ssl crt /etc/haproxy/server.pem ca-file /etc/haproxy/ca.crt verify required

    use_backend %[lua.choose_backend([ssl_c_s_dn], [ssl_c_i_dn])]
    #use_backend app
    default_backend app
    reqadd X-Forwarded-Proto:\ https if { ssl_fc }
    option forwardfor

.

/usr/sbin/lua-choose-backend.lua

function choose_backend(txn, arg1, arg2)
        core.log(core.info, "Hello World")
        core.log(core.info, arg1)
        core.log(core.info, arg2)

        return "app"
end

core.register_fetches("choose_backend", choose_backend)

.

$ haproxy -c -f /etc/haproxy/haproxy.cfg

[WARNING] 133/050028 (6381) : parsing [/etc/haproxy/haproxy.cfg:88] : 'acl' : sample fetch <lua.choose_backend([ssl_c_s_dn> failed with : missing closing ')' after arguments to fetch keyword 'lua.choose_backend'
[ALERT] 133/050028 (6381) : Proxy 'http-in': unable to find required use_backend: '%[lua.choose_backend([ssl_c_s_dn],'.
Subscribe
Share

Hung, I didn’t get your response.

Login to our website fill out, we have not yet established.


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.