I'm using OpenResty with nginx to auto-obtain SSL certs from Let's Encrypt. There's a lua function where you can allow certain domains. In this function, I have a regex to whitelist my domains. After I add a certain amount (not sure the exact amount), I start getting this error:
nginx: [emerg] too long lua code block, probably missing terminating characters in /usr/local/openresty/nginx/conf/nginx.conf:60.
Shrinking down that string makes the error go away.
I'm not familiar with lua, but here's the example code. I have a few hundred domains to add in here.
auto_ssl:set("allow_domain", function(domain)
return ngx.re.match(domain, "^(domain1.com|domain2.com|domain3.com....)$", "ijo")
end)
Do I need to define this string ahead of time, or maybe specify it's length somewhere?
EDIT ok, so I was thinking about this another way. Does anyone see an issue if I were to try this? Any sort of performance issues, or lua related things? Maybe there's a more efficient way of doing this?
auto_ssl:set("allow_domain", function(domain)
domains = [[
domain1.com
domain2.com
domain3.com
-- continues up to domain300.com
]]
i, j = string.find(domains, domain)
return i ~= nil
end)
OpenResty allows for loading more complex lua code through files. https://github.com/openresty/lua-nginx-module#init_by_lua_file That is just one directive. There are multiple ways you can load lua code. This way worked for me.