我在redhat 7.5服务器上安装了nginx 1.12,它也有LUA 5.1.4我下载了lua-nginx-module-0.10.13 tar ball并将它放在/ etc/nginx/modules下,但是我无法运行nginx使用LUA auth文件.
我在/ opt/openresty /下也有开放性.
http://openresty.org/en/installation.html 我在这里遵循"make"方法.
不幸的是,这台服务器无法访问互联网,所以我无法从git安装东西,这大大减缓了这一点.我不知道如何在这里添加模块.任何评论都会有所帮助.
这是我的nginx配置看起来像..
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;
}
}
Run Code Online (Sandbox Code Playgroud)
lua_access_file导致错误
nginx:[emerg] unknown指令"access_by_lua_file"我是否需要在配置中定义一些"include"来摆脱这个?
谢谢.
根据问题和我的理解,我正在将你的问题分解为小任务.
1)错误清楚地表明您没有正确安装Lua-nginx模块.
2)服务器无法访问互联网,因此无法从git下载. *
假设你正在从windows中对你的机器进行ssh.因此,请查看以下链接,将文件从Windows复制到Linux.
此步骤将获取服务器上的所有必需文件.
3)使用lua-nginx-module安装nginx的步骤.
lua nginx模块兼容性检查.
Nginx Compatibility
The latest version of this module is compatible with the following versions of Nginx:
1.13.x (last tested: 1.13.6)
1.12.x
1.11.x (last tested: 1.11.2)
1.10.x
1.9.x (last tested: 1.9.15)
1.8.x
1.7.x (last tested: 1.7.10)
1.6.x
Nginx cores older than 1.6.0 (exclusive) are not supported.
Run Code Online (Sandbox Code Playgroud)
先决条件
- Centos/RHEL [ 如果您的服务器正在使用互联网 ].
yum install -y wget unzip gcc make openssl-devel pcre-devel zlib-devel
Run Code Online (Sandbox Code Playgroud)
- 手动下载.rpm包并安装.
从RPM资源站点搜索先决条件
将文件复制到Linux框中
使用以下命令安装.
rpm -i rpm-package-name
Run Code Online (Sandbox Code Playgroud)
- 为先决条件安装Tarball.
下载源代码
$ cd /tmp/nginx-build
$ wget http://nginx.org/download/nginx-1.13.0.tar.gz
$ wget http://luajit.org/download/LuaJIT-2.0.4.tar.gz
$ wget -O nginx_devel_kit.tar.gz https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz
$ wget -O nginx_lua_module.tar.gz https://github.com/openresty/lua-nginx-module/archive/v0.10.8.tar.gz
Run Code Online (Sandbox Code Playgroud)提取
$ tar xvf LuaJIT-2.0.4.tar.gz
$ tar xvf nginx-1.11.10.tar.gz
$ tar xvf nginx_devel_kit.tar.gz
$ tar xvf nginx_lua_module.tar.gz
Run Code Online (Sandbox Code Playgroud)建立LuaJIT
要使用LuaJIT构建Nginx,我们需要首先构建LuaJIT.这就像make命令一样简单
$ cd /tmp/nginx-build/LuaJIT-2.0.4
$ make install
==== Building LuaJIT 2.0.4 ====
make -C src
make[1]: Entering directory `/tmp/nginx/LuaJIT-2.0.4/src'
...
...
ln -sf luajit-2.0.4 /usr/local/bin/luajit
==== Successfully installed LuaJIT 2.0.4 to /usr/local ====
Run Code Online (Sandbox Code Playgroud)建立Nginx
$ cd /tmp/nginx-build/nginx-1.11.10
$ LUAJIT_LIB=/usr/local/lib LUAJIT_INC=/usr/local/include/luajit-2.0 \
./configure \
--user=nobody \
--group=nobody \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-pcre \
--with-file-aio \
--with-http_realip_module \
--without-http_scgi_module \
--without-http_uwsgi_module \
--without-http_fastcgi_module ${NGINX_DEBUG:+--debug} \
--with-cc-opt=-O2 --with-ld-opt='-Wl,-rpath,/usr/local/lib' \
--add-module=/tmp/nginx/ngx_devel_kit-0.3.0 \
--add-module=/tmp/nginx/lua-nginx-module-0.10.8
$ make install
Run Code Online (Sandbox Code Playgroud)Syntanx检查
$ nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Run Code Online (Sandbox Code Playgroud)Nginx Lua测试
*根据你的nginx文件.
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'; }
Run Code Online (Sandbox Code Playgroud)重新加载/重新启动nginx
systemctl nginx restart
systemctl nginx reload.
Run Code Online (Sandbox Code Playgroud)
现在,在大多数操作系统(例如Ubuntu等)中,可以通过安装libnginx-mod-http-lua软件包来启用对Nginx的Lua支持。例如:
sudo apt install libnginx-mod-http-lua
Run Code Online (Sandbox Code Playgroud)
该包包含动态库和相应的load_module指令,其中/usr/share/nginx/modules-available/mod-http-lua.conf通常在安装包时启用(通过将其软链接到/etc/nginx/modules-enabled/目录中)。
| 归档时间: |
|
| 查看次数: |
4968 次 |
| 最近记录: |