OpenResty auto

编程入门 行业动态 更新时间:2024-10-15 18:23:16
OpenResty auto_ssl太长的lua代码块错误(OpenResty auto_ssl too long lua code block error)

我在nginx中使用OpenResty从Let's Encrypt自动获取SSL证书。 有一个lua函数,你可以允许某些域。 在这个函数中,我有一个正则表达式来将我的域名列入白名单。 添加一定数量(不确定确切数额)后,我开始出现此错误:

nginx: [emerg] too long lua code block, probably missing terminating characters in /usr/local/openresty/nginx/conf/nginx.conf:60.

收缩该字符串会导致错误消失。

我不熟悉lua,但这是示例代码。 我在这里添加了几百个域。

auto_ssl:set("allow_domain", function(domain) return ngx.re.match(domain, "^(domain1.com|domain2.com|domain3.com....)$", "ijo") end)

我是否需要提前定义该字符串,或者可能在某处指定它的长度?

编辑好吧,所以我正在想另一种方式。 如果我试试这个,有没有人看到问题? 任何类型的性能问题,或卢阿相关的事情? 也许这是一种更有效的方法吗?

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)

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允许通过文件加载更复杂的lua代码。 https://github.com/openresty/lua-nginx-module#init_by_lua_file这只是一个指令。 有多种方法可以加载lua代码。 这种方式对我有用。

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.

更多推荐

本文发布于:2023-08-03 20:51:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1398891.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:OpenResty   auto

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!