You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
global
# Path to haproxy-lua-http, below example assumes /usr/local/etc/haproxy/haproxy-lua-http/http.lua
lua-prepend-path /usr/local/etc/haproxy/http.lua
# Path to haproxy-auth-request
lua-load /usr/local/etc/haproxy/auth-request.lua
log stdout format raw local0 debug
When I check haproxy cfg I get errors:
haproxy -c -f haproxy.cfg
[NOTICE] (26946) : haproxy version is 2.4.2-553dee3
[NOTICE] (26946) : path to executable is /usr/local/sbin/haproxy
[ALERT] (26946) : parsing [haproxy.cfg:5] : Lua runtime error: error loading module 'json' from file '/usr/local/etc/haproxy/http.lua':
/usr/local/etc/haproxy/http.lua:673: too many C levels (limit is 200) in function at line 619 near 'v'
Pretty sure this is a dist issue with the various operating systems. Here's my test script I used to help diagnose it:
localjson=require"json"print("hello world")
Running that reveals the if the issue is exists because of the install or if it's something else (if it prints an error it's due to the versions installed of lua and lua-json which are conflicting, if it runs it's something else, if it runs after suggested fixes it shows it should now work), also reveals the search path lua is using (snippet 2). If you then use a tool like mlocate to find the locations json.lua exists you'll note that it may not exist for the version of lua you have installed. In which case you have to install a compatible lua version or use the workaround by @schklom.
# lua example.lua
lua: example.lua:1: module 'json' not found:
no field package.preload['json']
no file '/usr/local/share/lua/5.4/json.lua'
no file '/usr/local/share/lua/5.4/json/init.lua'
no file '/usr/local/lib/lua/5.4/json.lua'
no file '/usr/local/lib/lua/5.4/json/init.lua'
no file '/usr/share/lua/5.4/json.lua'
no file '/usr/share/lua/5.4/json/init.lua'
no file './json.lua'
no file './json/init.lua'
no file '/usr/local/lib/lua/5.4/json.so'
no file '/usr/lib/x86_64-linux-gnu/lua/5.4/json.so'
no file '/usr/lib/lua/5.4/json.so'
no file '/usr/local/lib/lua/5.4/loadall.so'
no file './json.so'
stack traceback:
[C]: infunction'require'
example.lua:1: in main chunk
[C]: in?
Activity
rocklee44 commentedon May 25, 2022
My server Centos 8(minimal) has already lua-5.3.4 installed , and I also installed lua-json
I fixed it by editing /usr/local/etc/haproxy/http.lua
It works fine now.
schklom commentedon Apr 23, 2023
I don't remember where I read this, but I loaded https://github.com/rxi/json.lua with
to work for Authelia, and it works.
james-d-elliott commentedon Apr 12, 2024
Pretty sure this is a dist issue with the various operating systems. Here's my test script I used to help diagnose it:
Running that reveals the if the issue is exists because of the install or if it's something else (if it prints an error it's due to the versions installed of lua and lua-json which are conflicting, if it runs it's something else, if it runs after suggested fixes it shows it should now work), also reveals the search path lua is using (snippet 2). If you then use a tool like mlocate to find the locations json.lua exists you'll note that it may not exist for the version of lua you have installed. In which case you have to install a compatible lua version or use the workaround by @schklom.
Some example outputs for Ubuntu 22.04:
# lua -v Lua 5.4.4 Copyright (C) 1994-2022 Lua.org, PUC-Rio# locate json.lua /usr/share/lua/5.1/json.lua /usr/share/lua/5.2/json.lua /usr/share/lua/5.3/json.luaFix for Ubuntu 22.04:
apt remove lua5.4 && apt install lua5.3Seems in this specific fix it doesn't fix it for haproxy, it still has issues loading the module which is very odd.
piengeng commentedon Dec 26, 2024
was on ubuntu 24.04 with
lua-jsonpackage, have to workaround with below, since 5.2/5.3 all point back to 5.1