Error while using Nginx lua module: libluajit-5.1.so.2: cannot open shared object file: No such file or directory

时光怂恿深爱的人放手 提交于 2021-02-17 06:31:11

问题


I am receiving below error with Nginx:

2020-12-24 10:41:46 INFO XMLTooling.SecurityHelper : loading certificate(s) from file (/etc/shibboleth/sp-encrypt-cert.pem)
2020-12-24 10:41:46 DEBUG Shibboleth.ServiceProvider : registered remoted message endpoint (default::getHeaders::Application)
2020-12-24 10:41:46 INFO Shibboleth.Listener : listener service starting
nginx: [emerg] dlopen() "/etc/nginx/modules/ngx_http_lua_module.so" failed (libluajit-5.1.so.2: cannot open shared object file: No such file or directory) in /etc/nginx/nginx.conf:9

I have declared all the required environment variable in dockerfile like below:

RUN export LUAJIT_INC=/usr/local/include/luajit-2.1
RUN export LUAJIT_LIB=/usr/local/lib/
RUN export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
RUN export LUA_INCLUDE_DIR=$LUAJIT_INC

I have checked libluajit-5.1.so.2 is present at path /usr/local/lib/

-rw-r--r-- 1 root root 890150 Dec 24 10:39 libluajit-5.1.a
lrwxrwxrwx 1 root root     22 Dec 24 10:39 libluajit-5.1.so -> libluajit-5.1.so.2.1.0
lrwxrwxrwx 1 root root     22 Dec 24 10:39 libluajit-5.1.so.2 -> libluajit-5.1.so.2.1.0
-rwxr-xr-x 1 root root 523944 Dec 24 10:39 libluajit-5.1.so.2.1.0
drwxr-xr-x 1 root root   4096 Dec 24 10:39 lua
drwxr-xr-x 3 root root   4096 Dec 24 10:40 luarocks
drwxr-xr-x 2 root root   4096 Dec 24 10:39 pkgconfig

Below is my nginx.conf file

user  nginx;
worker_processes  1;

error_log  /dev/stdout warn;
pid        /var/run/nginx.pid;
load_module /etc/nginx/modules/ngx_http_headers_more_filter_module.so;
load_module /etc/nginx/modules/ngx_http_shibboleth_module.so;
load_module /etc/nginx/modules/ndk_http_module.so;
load_module /etc/nginx/modules/ngx_http_lua_module.so;

events {
  worker_connections  1024;
}

http {
  include       /etc/nginx/mime.types;
  default_type  application/octet-stream;
  
  #lua_load_resty_core off;
  lua_package_path "/usr/local/lib/lua/?.lua;;";

  log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"';

  access_log /dev/stdout  main;

  sendfile        on;
  #tcp_nopush     on;

  keepalive_timeout  65;

  #gzip  on;

  include /etc/nginx/conf.d/*.conf;
}

Below is my docker file:

    FROM centos:7
    
    ARG NGINX_VERSION="1.18.0"
    
    RUN yum -y install nginx-$NGINX_VERSION
    #Install pre requirements for nginx_lua_module
    RUN cd /usr/local/src && git clone https://github.com/simpl/ngx_devel_kit.git
    RUN cd /usr/local/src && git clone https://github.com/openresty/lua-nginx-module.git
    
    RUN cd /usr/local/src && git clone https://github.com/openresty/luajit2.git && cd luajit2 && \
        make && make install
    
    RUN cd /usr/local/src && git clone https://github.com/openresty/lua-resty-core.git && cd lua-resty-core && \
        make install
    RUN cd /usr/local/src && git clone https://github.com/openresty/lua-resty-lrucache.git && cd lua-resty-lrucache && \
        make install
    RUN yes | cp -rf /usr/local/lib/* /etc/nginx/modules/
    RUN ls -l /usr/local/lib/
    RUN export LUAJIT_INC=/usr/local/include/luajit-2.1
    RUN export LUAJIT_LIB=/usr/local/lib/
    RUN export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
    RUN export LUA_INCLUDE_DIR=$LUAJIT_INC
    
    
    # Copy nginx-lua-module
    COPY ./docker/shib_files/ndk_http_module.so /etc/nginx/modules
    COPY ./docker/shib_files/ngx_http_lua_module.so /etc/nginx/modules
    
    #Add shibboleth logs to docker stdout
    RUN rm -f /var/log/shibboleth/shibd*.log && \
        ln -s /dev/stdout /var/log/shibboleth/shibd.log && \
        ln -s /dev/stderr /var/log/shibboleth/shibd_warn.log
        
    #Add nginx logs to docker stdout - currently congiguration moved to nginx.conf 
    
    # Run Shibboleth Authorizer/Responder with Supervisor
    COPY ./docker/shib_files/entrypoint.sh /opt/entrypoint.sh
    COPY ./docker/shib_files/shibboleth-sp.ini /etc/supervisord.d/shibboleth-sp.ini
    
    # We need to load dynamic modules
    COPY ./docker/shib_files/nginx.conf /etc/nginx/nginx.conf
    # Merge with proxy-nginx.conf
    COPY ./docker/shib_files/auth-nginx.conf /etc/nginx/conf.d/default.conf
    COPY ./docker/shib_files/shibboleth2.xml /etc/shibboleth/shibboleth2.xml
    COPY ./docker/shib_files/attribute-map.xml /etc/shibboleth/attribute-map.xml
    
    # for PingFederate dev
    COPY --chown=shibd:shibd ./docker/shib_files/idp_meta_dev.xml /etc/shibboleth/localDir/49801fc5363450ba300e102b7c8b3b41eaa07633.xml
    # for PingFederate prod
    COPY --chown=shibd:shibd ./docker/shib_files/idp_meta_prod.xml /etc/shibboleth/localDir/141570ad90b90ff8718048c3c675472d14fb5c4b.xml
    
    COPY ./docker/shib_files/shibd.logger /etc/shibboleth/shibd.logger
    
    COPY ./docker/shib_files/private_ssl/nginx.crt /etc/ssl/certs/nginx.crt
    COPY ./docker/shib_files/private_ssl/nginx.key /etc/ssl/certs/nginx.key
    
    COPY --chown=shibd:shibd ./docker/shib_files/sp-encrypt-cert.pem /etc/shibboleth/sp-encrypt-cert.pem
    COPY --chown=shibd:shibd ./docker/shib_files/sp-encrypt-key.pem /etc/shibboleth/sp-encrypt-key.pem
    COPY --chown=shibd:shibd ./docker/shib_files/sp-signing-cert.pem /etc/shibboleth/sp-signing-cert.pem
    COPY --chown=shibd:shibd ./docker/shib_files/sp-signing-key.pem /etc/shibboleth/sp-signing-key.pem
    RUN ls -l /usr/local/lib/
    RUN ls -l /usr/local/include/
    RUN export LUAJIT_INC=/usr/local/include/luajit-2.1
    RUN export LUAJIT_LIB=/usr/local/lib/
    RUN export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
    RUN export LUA_INCLUDE_DIR=$LUAJIT_INC
    EXPOSE 80
    EXPOSE 443
    
    ENTRYPOINT ["/opt/entrypoint.sh"]
    
    CMD ["nginx", "-g", "daemon off;"]

I have added ndk_http_module.so and ngx_http_lua_module.so under/docker/shib_files mannually and Dockerfile is copying these modules to /etc/nginx/modules. Kindly Assist.

来源:https://stackoverflow.com/questions/65437633/error-while-using-nginx-lua-module-libluajit-5-1-so-2-cannot-open-shared-objec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!