Closed ghost closed 8 years ago
http { include mime.types; default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
# include lua_resty_waf in the appropriate paths
lua_package_path '/home/sunny/openresty-1.9.7.4/install/lualib/lua-resty-waf/?.lua;;';
lua_package_cpath '/home/sunny/openresty-1.9.7.4/install/lualib/lua-resty-waf/?.lua;;';
# use resty.core for performance improvement, see the status note above
require "resty.core"
# require the base module
local lua_resty_waf = require "waf"
# define options that will be inherited across all scopes
lua_resty_waf.default_option("debug", true)
lua_resty_waf.default_option("mode", "ACTIVE")
# perform some preloading and optimization
lua_resty_waf.init()
server {
listen 80;
server_name localhost;
location / {
# Ignore this, had added for testing
content_by_lua '
ngx.say("<p>hello, world</p>")
';
}
}
}
$ sudo ./nginx/sbin/nginx -T nginx: [emerg] unknown directive "require" in /home/sunny/openresty-1.9.7.4/install/nginx/conf/nginx.conf:42 nginx: configuration file /home/sunny/openresty-1.9.7.4/install/nginx/conf/nginx.conf test failed
@sunny137 you need to wrap your lua code in an init_by_lua
block
I suppose the synopsis should have the proper syntax as well. Whoops! I'll fix that shortly!
@sunny137 your config should look like this:
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
# include lua_resty_waf in the appropriate paths
lua_package_path '/home/sunny/openresty-1.9.7.4/install/lualib/lua-resty-waf/?.lua;;';
lua_package_cpath '/home/sunny/openresty-1.9.7.4/install/lualib/lua-resty-waf/?.lua;;';
init_by_lua '
# use resty.core for performance improvement, see the status note above
require "resty.core"
# require the base module
local lua_resty_waf = require "waf"
# define options that will be inherited across all scopes
lua_resty_waf.default_option("debug", true)
lua_resty_waf.default_option("mode", "ACTIVE")
# perform some preloading and optimization
lua_resty_waf.init()
';
server {
listen 80;
server_name localhost;
location / {
# Ignore this, had added for testing
content_by_lua '
ngx.say("<p>hello, world</p>")
';
}
}
}
Cool, it works now. I see that you have already updated synopsis. Thanks for quick response.
I am running into some silly errors while trying out resty waf. While starting nginx with changes made as shown in readme.synopsis, I get
unknown directive "require"
I think, I am missing something basic here. If someone can post following, it will help. I will add it to the documentation later.
Once this is done, I will take up adding Dockerfile for the same.