Chapter 8. Integrating Lua with NGINX

NGINX is extensible to handle varying use cases. In this chapter, we'll be exploring some possibilities of extending NGINX with Lua, an embedded scripting language designed for just such a purpose. The topics we'll be covering include the following:

  • The ngx_lua module
  • Integrating with Lua
  • Logging with Lua

The ngx_lua module

Similar in intent to the included perl module, the third-party ngx_lua module was made to cover use cases that couldn't be solved with configuration alone. Due to its embeddable design and coroutine (green threading) implementation, Lua serves this purpose well because it doesn't block an entire worker as the perl module can.

The OpenResty project (https://openresty.org/) is the official source ...

Get Mastering NGINX - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.