How do I serve a single static file from HAProxy?

You should never access the file system from LUA. Especially not based on user-triggered requests:

The list of prohibited standard Lua functions during the runtime contains all those that do filesystem access:

  • os.remove()
  • os.rename()
  • os.tmpname()
  • package.*()
  • io.*()
  • file.*()

You CANNOT emulate a webserver with LUA, those are blocking syscalls, they don’t belong in an event driven software like haproxy.

In haproxy 2.2, you can use http-request return if the errorfile workaround disgusts you.

2 Likes