How-to: OPNsense + HAProxy + Multi-LUA

This page summarizes the projects mentioned and recommended in the original post on /r/opnsense

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • haproxy-auth-request

    auth-request allows you to add access control to your HTTP services based on a subrequest to a configured HAProxy backend.

  • A lot of the more advanced HAproxy configs for SSO (think Authelia for example) require the use of Lua scripts which would be fine, but the scripts themselves need to reference OTHER scripts. For example haproxy-auth-request requires the use of haproxy-lua-http which needs to reference a JSON library such as json.lua. You usually will see statement such as local http = require("haproxy-lua-http") which indicates our script very explicitly is looking for that other script.

  • haproxy-lua-http

    Simple Lua HTTP helper && client for use with HAProxy.

  • A lot of the more advanced HAproxy configs for SSO (think Authelia for example) require the use of Lua scripts which would be fine, but the scripts themselves need to reference OTHER scripts. For example haproxy-auth-request requires the use of haproxy-lua-http which needs to reference a JSON library such as json.lua. You usually will see statement such as local http = require("haproxy-lua-http") which indicates our script very explicitly is looking for that other script.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • json.lua

    A lightweight JSON library for Lua

  • A lot of the more advanced HAproxy configs for SSO (think Authelia for example) require the use of Lua scripts which would be fine, but the scripts themselves need to reference OTHER scripts. For example haproxy-auth-request requires the use of haproxy-lua-http which needs to reference a JSON library such as json.lua. You usually will see statement such as local http = require("haproxy-lua-http") which indicates our script very explicitly is looking for that other script.

  • plugins

    OPNsense plugin collection (by opnsense)

  • This would all be well and good IF AND ONLY IF THE FREAKING HAPROXY PLUGIN DIDN'T RENAME THE SCRIPTS WHEN YOU UPLOAD THEM. When you name the script in the plugin, it is only for sorting purposes. The actual config will contain something like lua-load /tmp/haproxy/lua/6106c1930d3869.70081312.lua , while the other script is still looking haproxy-lua-http. Furthermore, that dot in the middle of the randomly generated file name throws off the require statements! There is an open issue about this on Github and a forum post here as well.

  • luabundler

    CLI tool for bundling several Lua files into a single file.

  • So short of trying to fix the code, of which most of us are not equipped to do, what can we do? Well, there is a really fun little tool called luabundler. This tool will analyze the Lua file you feed it, figure out all the dependency Lua scripts based on the require statements, and then wrap them all up in one self-contained Lua script! All we need is Node, the bundler, and the individual scripts.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts