nginx - 无法使用 lua nginx 配置 OIDC
问题描述
我正在关注下面的博客(https://developers.redhat.com/blog/2018/10/08/configuring-nginx-keycloak-oauth-oidc/)来设置 NGINX lua oidc。以下是我的安装和设置,无法运行以下命令
Install all the Lua modules using luarocks:
# luarocks install lua-cjson
# luarocks install lua-resty-openidc
结果:
[root@samplesys nginx-lua]# yum install luarocks
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.netdepot.com
* epel: mirror.lax.genesisadaptive.com
* extras: mirror.netdepot.com
* updates: mirror.netdepot.com
Package luarocks-2.3.0-1.el7.x86_64 already installed and latest version
Nothing to do
[root@sample nginx-lua]# luarocks install lua-cjson
Warning: falling back to curl - install luasec to get native HTTPS support
Warning: Failed searching manifest: Failed fetching manifest for https://luarocks.org - Failed downloading https://luarocks.org/manifest-5.1 - /var/cache/luarocks/https___luarocks.org/manifest-5.1
Warning: Failed searching manifest: Failed fetching manifest for https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/ - Failed downloading https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/manifest-5.1 - /var/cache/luarocks/https___raw.githubusercontent.com_rocks-moonscript-org_moonrocks-mirror_master_/manifest-5.1
Warning: Failed searching manifest: Failed extracting manifest file: failed extracting /var/cache/luarocks/http___luafr.org_moonrocks_/manifest-5.1.zip
Warning: Failed searching manifest: Failed extracting manifest file: failed extracting /var/cache/luarocks/http___luarocks.logiceditor.com_rocks/manifest-5.1.zip
lua-cjson not found for Lua 5.1.
Checking if available for other Lua versions...
Checking for Lua 5.2...
Checking for Lua 5.3...
Checking for Lua 5.4...
Error: No results matching query were found for Lua 5.1.
[root@sample nginx-lua]# luarocks install lua-resty-openidc
Warning: falling back to curl - install luasec to get native HTTPS support
Warning: Failed searching manifest: Failed fetching manifest for https://luarocks.org - Failed downloading https://luarocks.org/manifest-5.1 - /var/cache/luarocks/https___luarocks.org/manifest-5.1
Warning: Failed searching manifest: Failed fetching manifest for https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/ - Failed downloading https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/manifest-5.1 - /var/cache/luarocks/https___raw.githubusercontent.com_rocks-moonscript-org_moonrocks-mirror_master_/manifest-5.1
Warning: Failed searching manifest: Failed extracting manifest file: failed extracting /var/cache/luarocks/http___luafr.org_moonrocks_/manifest-5.1.zip
Warning: Failed searching manifest: Failed extracting manifest file: failed extracting /var/cache/luarocks/http___luarocks.logiceditor.com_rocks/manifest-5.1.zip
lua-resty-openidc not found for Lua 5.1.
Checking if available for other Lua versions...
Checking for Lua 5.2...
Checking for Lua 5.3...
Checking for Lua 5.4...
Error: No results matching query were found for Lua 5.1.
解决方案
这里有几件事是错误的:
- 编译 nginx 并手动添加 lua-nginx-module 不是安装 openresty 的推荐方式。引用自述文件:
强烈建议使用捆绑了 Nginx、ngx_lua(此模块)、LuaJIT 以及其他强大的 Nginx 模块和 Lua 库的 OpenResty 版本。
教程中使用的 Lua 版本似乎是 PUC Lua 5.1,它真的没有任何用处了;人们使用 5.1 的原因是 LuaJIT 实现了那个版本。我不记得 openresty 在多大程度上仍然支持那个版本,但它的更高版本肯定主要是为了与 LuaJIT 一起使用而构建的。
如果您使用的是 openresty 版本,则不需要安装
lua-cjson
,因为它已经捆绑在一起(请参阅自述文件)查看您收到的错误
Failed fetching manifest for https://luarocks.org - Failed downloading https://luarocks.org/manifest-5.1
,似乎 luarocks 无法下载清单文件,这可能是 luarocks.org 的临时问题(它对我有用,因为我正在写这个答案),或者您的网络有问题。wget
尝试使用or之类的工具从错误消息中下载 URLcurl
并查看它是否有效(curl
甚至已安装?)
推荐阅读
- python - 根据缺少的日期时间值添加空数据框行
- html - 如何使一个 HTML 元素与另一个元素成比例地动态调整大小?
- java - 通过 Jest 将 Elasticsearch 索引的一部分重新索引到新索引上
- delphi - 如何使用 CNG 从智能卡(USB 令牌)获取证书存储?
- python - 如何使用用户输入使用 Tkinter 编写输出?
- jmeter - 如何计算在 JMeter 中完成一个线程组所花费的总时间?
- sql - 在 SQL Server 中计算年龄范围
- javascript - 使用 axios 在同一站点上单独的身份验证会话
- r - 在 ggplot 中将 geom_line mean 添加到重新排序的 geom_point 图
- microsoft-graph-api - Microsoft Graph delta:重复的日历事件返回不正确的开始/结束