Openresty nginx 抛出 zlib 未找到错误
Openresty nginx throwing zlib not found error
我已经安装了openresty nginx服务器。这是我的配置文件:
http {
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 /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
# set search paths for pure Lua external libraries (';;' is the default path):
lua_package_path '/usr/local/openresty/?.lua;/usr/local/openresty/lualib/?.lua;/usr/local/openresty/lualib/resty/?.lua;/usr/local/openresty/lualib/ngx/?.lua;/usr/local/openresty/site/lualib/?.lua;;';
# set search paths for Lua external libraries written in C (can also use ';;'):
lua_package_cpath '/usr/local/openresty/?.so;/usr/local/openresty/lualib/?.so;/usr/local/openresty/lualib/resty/?.so;/usr/local/openresty/lualib/ngx/?.so;/usr/local/openresty/site/lualib/?.so;;';
server {
listen 81;
location / {
proxy_pass http://localhost:4040;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Cluster-Client-Ip $remote_addr;
proxy_pass_request_headers on;
proxy_redirect off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# for deflate/uncompress request
client_max_body_size 512k;
client_body_buffer_size 512k;
set $max_chunk_size 10240;
set $max_body_size 524288;
rewrite_by_lua_file /opt/se/nginx-scripts/inflate_body.lua;
}
}
}
此处的lua文件引用取自http://www.pataliebre.net/howto-make-nginx-decompress-a-gzipped-request.html以支持在nginx端接受gzip格式的请求。
当我启动服务器时,它已启动,但以 gzip 格式发送请求会引发内部服务器错误,并出现以下错误:
/opt/se/nginx-scripts/inflate_body.lua:20: in function 'inflate_body'
/opt/se/nginx-scripts/inflate_body.lua:57: in function
, client: 192.168.3.30,
server: , request: "POST / HTTP/1.1", host: "192.168.3.30:81"
2018/06/06 15:08:28 [error] 36232#36232: *1 lua entry thread aborted: runtime error: /opt/se/nginx-scripts/inflate_body.lua:20:
module 'zlib' not found: no field package.preload['zlib'] no file
'/usr/local/openresty/zlib.lua' no file
'/usr/local/openresty/lualib/zlib.lua' no file
'/usr/local/openresty/lualib/resty/zlib.lua' no file
'/usr/local/openresty/lualib/ngx/zlib.lua' no file
'/usr/local/openresty/site/lualib/zlib.lua' no file
'/usr/local/openresty/site/lualib/zlib.ljbc' no file
'/usr/local/openresty/site/lualib/zlib/init.ljbc' no file
'/usr/local/openresty/lualib/zlib.ljbc' no file
'/usr/local/openresty/lualib/zlib/init.ljbc' no file
'/usr/local/openresty/site/lualib/zlib.lua' no file
'/usr/local/openresty/site/lualib/zlib/init.lua' no file
'/usr/local/openresty/lualib/zlib.lua' no file
'/usr/local/openresty/lualib/zlib/init.lua' no file './zlib.lua' no
file '/usr/local/openresty/luajit/share/luajit-2.1.0-beta3/zlib.lua'
no file '/usr/local/share/lua/5.1/zlib.lua' no file
'/usr/local/share/lua/5.1/zlib/init.lua' no file
'/usr/local/openresty/luajit/share/lua/5.1/zlib.lua' no file
'/usr/local/openresty/luajit/share/lua/5.1/zlib/init.lua' no file
'/usr/local/openresty/zlib.so' no file
'/usr/local/openresty/lualib/zlib.so' no file
'/usr/local/openresty/lualib/resty/zlib.so' no file
'/usr/local/openresty/lualib/ngx/zlib.so' no file
'/usr/local/openresty/site/lualib/zlib.so' no file
'/usr/local/openresty/site/lualib/zlib.so' no file
'/usr/local/openresty/lualib/zlib.so' no file './zlib.so' no file
'/usr/local/lib/lua/5.1/zlib.so' no file
'/usr/local/openresty/luajit/lib/lua/5.1/zlib.so' no file
'/usr/local/lib/lua/5.1/loadall.so'
在互联网上阅读此问题后,我尝试手动设置 lua_package_path 和 lua_package_cpath,但仍然无济于事。我不确定我应该采取什么其他步骤来解决这个问题?
您的系统没有安装合适的 zlib 共享模块。
在 debian 风格的发行版上,这对我有用:sudo apt-get install zlib1g
。
如果您有其他东西,请找到合适的包。
我已经安装了openresty nginx服务器。这是我的配置文件:
http {
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 /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
# set search paths for pure Lua external libraries (';;' is the default path):
lua_package_path '/usr/local/openresty/?.lua;/usr/local/openresty/lualib/?.lua;/usr/local/openresty/lualib/resty/?.lua;/usr/local/openresty/lualib/ngx/?.lua;/usr/local/openresty/site/lualib/?.lua;;';
# set search paths for Lua external libraries written in C (can also use ';;'):
lua_package_cpath '/usr/local/openresty/?.so;/usr/local/openresty/lualib/?.so;/usr/local/openresty/lualib/resty/?.so;/usr/local/openresty/lualib/ngx/?.so;/usr/local/openresty/site/lualib/?.so;;';
server {
listen 81;
location / {
proxy_pass http://localhost:4040;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Cluster-Client-Ip $remote_addr;
proxy_pass_request_headers on;
proxy_redirect off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# for deflate/uncompress request
client_max_body_size 512k;
client_body_buffer_size 512k;
set $max_chunk_size 10240;
set $max_body_size 524288;
rewrite_by_lua_file /opt/se/nginx-scripts/inflate_body.lua;
}
}
}
此处的lua文件引用取自http://www.pataliebre.net/howto-make-nginx-decompress-a-gzipped-request.html以支持在nginx端接受gzip格式的请求。
当我启动服务器时,它已启动,但以 gzip 格式发送请求会引发内部服务器错误,并出现以下错误:
/opt/se/nginx-scripts/inflate_body.lua:20: in function 'inflate_body' /opt/se/nginx-scripts/inflate_body.lua:57: in function , client: 192.168.3.30, server: , request: "POST / HTTP/1.1", host: "192.168.3.30:81" 2018/06/06 15:08:28 [error] 36232#36232: *1 lua entry thread aborted: runtime error: /opt/se/nginx-scripts/inflate_body.lua:20: module 'zlib' not found: no field package.preload['zlib'] no file '/usr/local/openresty/zlib.lua' no file '/usr/local/openresty/lualib/zlib.lua' no file '/usr/local/openresty/lualib/resty/zlib.lua' no file '/usr/local/openresty/lualib/ngx/zlib.lua' no file '/usr/local/openresty/site/lualib/zlib.lua' no file '/usr/local/openresty/site/lualib/zlib.ljbc' no file '/usr/local/openresty/site/lualib/zlib/init.ljbc' no file '/usr/local/openresty/lualib/zlib.ljbc' no file '/usr/local/openresty/lualib/zlib/init.ljbc' no file '/usr/local/openresty/site/lualib/zlib.lua' no file '/usr/local/openresty/site/lualib/zlib/init.lua' no file '/usr/local/openresty/lualib/zlib.lua' no file '/usr/local/openresty/lualib/zlib/init.lua' no file './zlib.lua' no file '/usr/local/openresty/luajit/share/luajit-2.1.0-beta3/zlib.lua' no file '/usr/local/share/lua/5.1/zlib.lua' no file '/usr/local/share/lua/5.1/zlib/init.lua' no file '/usr/local/openresty/luajit/share/lua/5.1/zlib.lua' no file '/usr/local/openresty/luajit/share/lua/5.1/zlib/init.lua' no file '/usr/local/openresty/zlib.so' no file '/usr/local/openresty/lualib/zlib.so' no file '/usr/local/openresty/lualib/resty/zlib.so' no file '/usr/local/openresty/lualib/ngx/zlib.so' no file '/usr/local/openresty/site/lualib/zlib.so' no file '/usr/local/openresty/site/lualib/zlib.so' no file '/usr/local/openresty/lualib/zlib.so' no file './zlib.so' no file '/usr/local/lib/lua/5.1/zlib.so' no file '/usr/local/openresty/luajit/lib/lua/5.1/zlib.so' no file '/usr/local/lib/lua/5.1/loadall.so'
在互联网上阅读此问题后,我尝试手动设置 lua_package_path 和 lua_package_cpath,但仍然无济于事。我不确定我应该采取什么其他步骤来解决这个问题?
您的系统没有安装合适的 zlib 共享模块。
在 debian 风格的发行版上,这对我有用:sudo apt-get install zlib1g
。
如果您有其他东西,请找到合适的包。