Nginx调用lua模块失败
来源:4-32 Nginx与Lua的开发_实战场景灰度发布场景演示2
qq_絕對C_0
2020-03-11
老师,按照你的方法我安装了lua模块后检查了nginx配置语法出现nginx: [emerg] unknown directive “content_by_lua_file” in /usr/local/nginx/conf/nginx.conf:50这个报错
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
location /hello {
default_type 'text/plain';
content_by_lua_file 'ngx.say("hello, lua")';
}
location /myip {
default_type 'text/plain';
content_by_lua '
clientIP = ngx.req.get_headers()["x_forwarded_for"]
ngx.say("IP:",clientIP)
';
}
location / {
default_type "text/html";
content_by_lua_file /usr/local/nginx/conf/dep.lua;
#add_after_body "$http_x_forwarded_for";
}
#
location @server{
proxy_pass http://127.0.0.1:9090;
}
location @server_test{
proxy_pass http://127.0.0.1:8080;
}
写回答
1回答
-
Jeson
2020-03-16
这个需要看下你的nginx_lua_module版本,如果在:
版本0.9.17以上,使用content_by_lua_block,lua-nginx-module
00
相似问题