我尝试使用init_by_lua指令:https://github.com/chaoslawful/lua-nginx-module#init_by_lua
和nginx无法启动,日志中显示此消息:
2014/04/08 17:33:53 [emerg] 2105#0: "init_by_lua" directive is not allowed here in /genap/genap-nginx.conf:6
nginx conf文件是:
worker_processes 1;
error_log logs/error.log;
init_by_lua 'local zaz = 4321';
events {
worker_connections 1024;
}
http {
server {
lua_code_cache off;
listen 80;
location / {
default_type text/html;
content_by_lua_file /vagrant/genap_host_proxy/content.lua;
}
}
}
我尝试将init_by_lua放在http和服务器块中,我得到了同样的错误init_by_lua
答案 0 :(得分:1)
您是否尝试将其放入http {...}块?
http {
init_by_lua 'local zaz = 4321';
server { ... }
}
答案 1 :(得分:1)
init_by_lua
仅允许http
内容:http://wiki.nginx.org/HttpLuaModule#init_by_lua
http {
init_by_lua '
require "resty.core"
';
}