Nginx: unknown directive “rewrite_by_lua”

“unknown directive rewrite_by_lua” : How to fix this error?

When you work with Nginx, a powerful feature is to take advantage of Lua scripting language directly in your configuration files.

You can come across solutions that involve Lua scripting. If your setup doesn’t include Lua module, you’ll get an error message like this in nginx error.log :

2016/11/23 09:51:58 [emerg] 12730#0: unknown directive "rewrite_by_lua" in /etc/nginx/sites-enabled/v3.conf:59

Lua is available with nginx through ngx_http_lua_module. This module is installed with nginx-extras package (nginx web/proxy server (extended version))

$ apt-get install nginx-extras

Remember that this package contains a full working version of nginx server, it will remove packages like nginx-full or nginx-light.

Also you can find source code and documentation on github : ngx_http_lua_module – Embed the power of Lua into Nginx HTTP Servers.