I'm writing lua script that is going to run inside HAproxy
using it's Lua API.
My script is using socket
package which I want to install on my machine.
Currently I'm running inside docker and my dockerfile looks like this:
FROM haproxy:1.7
RUN apt-get update -y && apt-get install curl luarocks -y
RUN luarocks install luasocket
EXPOSE 80 9000
COPY 500error.json.http /etc/haproxy/errorfiles/
COPY hello_world.lua /etc/haproxy/scripts/
my script have the next line:
local http = require('socket.http')
which works okay when running lua interpreter but not when running haproxy:
[ALERT] 298/104833 (8) : parsing [/usr/local/etc/haproxy/haproxy.cfg:5] : lua runtime error: /etc/haproxy/scripts/hello_world.lua:1: module 'socket.http' not found:
How should I load this correctly to haproxy?
socket.http
with HAProxy, if it performs any blocking operations. It has been a while since I did any intense Lua programming with HAProxy, but I remember doing remote HTTP requests "by hand," using HAProxy's built in Lua sockets capability to send raw HTTP requests built by my code, and parsing the responses with regexes, and I had to use hard-coded IP addresses since I no asynchronous DNS capability. YMMV. – Misappropriate