Anyone serving PHP-FPM directly from HAProxy?

This is a very interesting feature, wondering if anyone is already doing this and would share some wisdom…

Additionally, could the static content be served from HAProxy directly hence no more need for an HTTP server?

No, haproxy will never serve files and will never be a replacement for a webserver.

What about the Native Response Generator?
https://eleph.haproxy.com/

The video explicitly mentions that haproxy is not a replacement for a webserver.

You can serve the content of a file with errorfiles or http-request return, but:

  • in needs to fit 1 buffer (that’s generally 16kb)
  • it’s read into memory at startup, if you update the file and want haproxy to start serving the new instead of the old one, you need to reload haproxy

Make no mistake. Haproxy is not a webserver and probably never will be.

1 Like

What’s with using a lua script service to serving files?
I don’t use it for regularly serving the files of a complete application, but if there is no need for special, flexible configuration, restrictions, serving bigger not-memory-mapped files and other stuff which is already built and proven in a webserver, why not?

1 Like

You should never ever use LUA to read files from the disk.

1 Like

Thanks @lukastribus
I understand HAP is not an HTTP server.
My use case is a fully PHP APP with just the logo and a few other files (some css mostly) as the only static content, hence I was wondering if I could entirely avoid using an HTTP server by serving those little static pieces from HAP directly, as this would greatly reduce my footprint when replicating this APP.

Thanks @arlecchino Worth checking for sure, LUA is not in my skillset, but I’ll find someone who can help. Providing we don’t use any of the blocking syscalls Lukas mentioned, it might work!
At least it will be a great experiment, even if it does not work/perform well…

All of those are blocking syscalls. You can’t do this.