nginxlua

Adding LUA module to nginx


I rpm installed nginx 1.12 on a redhat 7.5 server and It also has LUA 5.1.4 I downloaded lua-nginx-module-0.10.13 tar ball and put it under /etc/nginx/modules, but I am not able to run nginx with LUA auth file.

I also have openresty under /opt/openresty/ ..

http://openresty.org/en/installation.html I followed the "make" method here.

Unfortunately this server doesnt have access to the internet so I cant install stuff from git which slows this down considerably. I am not sure how to add the module here. Any comments would be helpful.

This is what my nginx config looks like ..

server
{
    listen 80;

    access_log  /opt/elk/logs/nginx/access.log  main;

    #auth_basic "admin";
    #auth_basic_user_file "/etc/nginx/passwd";

    client_max_body_size 100M;

    location /
    {
        proxy_pass http://127.0.0.1:9200;

        keepalive_timeout 300s;

        #auth_basic on;
        auth_basic "admin";
        auth_basic_user_file "/etc/nginx/passwd";

        access_by_lua_file '/etc/nginx/authorized.lua';
    }

    error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html
    {
        root   /usr/share/nginx/html;
    }
}

The lua_access_file is causing an error

nginx: [emerg] unknown directive "access_by_lua_file" Is there some "include" I need to define in the config to get rid of this ?

Thanks.


Solution

  • I am breaking down your problem into the small task, as per question and my understanding.

    1) The error clearly says that you have not install Lua-nginx-module properly.

    Lua-nginx-module documentation

    2) The server does not have access to the internet so cannot download from git. *

    how-to-copy-files-from-one-machine-to-another-using-ssh

    3) Steps to install nginx with lua-nginx-module.

    1. Search the prerequisites from the RPM resource site

    2. Copy the file in your Linux box

      • Please refer above point (2)"The server does not have access to the internet so cannot download from git".
      1. Install with the following command.

          rpm -i rpm-package-name
        

      Install-rpm-file-on-linux

    - Tarball installation for prerequisites.

     - [Installing gcc from source code ][6]         Similarly,you can look for
              other prerequistes.
    

    how-to-reload-nginx-systemctl-or-nginx-s