Quantcast
Channel: HAProxy community - Latest topics
Viewing all articles
Browse latest Browse all 4718

How to extend Haproxy with Lua

$
0
0

@jl2035 wrote:

Hi. I’m trying to follow this article: https://www.haproxy.com/blog/5-ways-to-extend-haproxy-with-lua/

I’ve cloned haproxy from github and compiled it myself with:
make -j $(nproc) TARGET=linux-glibc USE_OPENSSL=1 USE_ZLIB=1 USE_LUA=1 USE_PCRE=1 USE_SYSTEMD=1

I’ve copied the code from the article and it doesn’t work for me. This is the example function:

core.register_fetches("greater_than", function(txn, var1, var2)
    local number1 = tonumber(txn:get_var(var1))
    local number2 = tonumber(txn:get_var(var2))
    if number1 > number2 then return true
    else return false end
end)

But I’m getting this error:

ua sample-fetch ‘greater_than’: runtime error: /home/user/projects/haproxy/hlib.lua:17: bad argument #1 to ‘Debug’ (string expected, got nil) from [C] field ‘Debug’, /home/user/projects/haproxy/hlib.lua:17 C function line 13.
[ALERT] 329/141214 (32243) : Lua sample-fetch ‘greater_than’: runtime error: /home/user/projects/haproxy/hlib.lua:17: bad argument #1 to ‘Debug’ (string expected, got nil) from [C] field ‘Debug’, /home/user/projects/haproxy/hlib.lua:17 C function line 13.

Can somebody explain why this article is off? It was written on May 24, 2019, so not that long ago. Am I doing something wrong?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4718

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>