0

I have found that to use LUA with Nginx I need to either:

I wonder how to build the module itself and then load it in the packaged Nginx. I am reluctant to build the Nginx as it means I would lose the package updates. How can I do that?

Leos Literak
  • 305
  • 4
  • 13

1 Answers1

1

I wonder how to build the module itself and then load it in the packaged Nginx.

To build the module itself you can fetch any existing module SRPM for an NGINX module and adjust as needed. The essential there is making sure you pass --with-compat to the NGINX configure script so that the module does not have to be compiled with exact same arguments as the NGINX you will use it with.

You will also have to build a separate package for the luajit2, to benefit from faster Lua execution (or ensure it is linked in statically in the module package).

Building the separate luajit2 package is a good idea, because then it is decoupled from the module and you can update it separately when the new version is released.

You'll then have to monitor NGINX releases / module / luajit2 library releases to continuously rebuild the module/library package and then apply it to a repository you manually set up.

At the end of the day, we decided that doing this whole thing ourselves was an overkill and opted for the GetPageSpeed repository which provides both Lua module and the faster luajit2. I say it saved some buck, because NGINX mainline is released around every 4–6 weeks, where we can just yum upgrade to the new NGINX/modules (there aren't just Lua modules there, but we also use PageSpeed and Brotli from them).

The freeware alternatives which are the mentioned OpenResty did not cut it as they tend to rely on older NGINX versions and we want the latest mainline NGINX available.

For an amateur project, I'd say don't bother and compile it. But for a production use case, I would not recommend compilation due to security risks and all the maintenance hassle.