首页 > 解决方案 > 无法使用 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.

标签: nginxlualua-resty-openidc

解决方案


这里有几件事是错误的:

  1. 编译 nginx 并手动添加 lua-nginx-module 不是安装 openresty 的推荐方式。引用自述文件

强烈建议使用捆绑了 Nginx、ngx_lua(此模块)、LuaJIT 以及其他强大的 Nginx 模块和 Lua 库的 OpenResty 版本。

  1. 教程中使用的 Lua 版本似乎是 PUC Lua 5.1,它真的没有任何用处了;人们使用 5.1 的原因是 LuaJIT 实现了那个版本。我不记得 openresty 在多大程度上仍然支持那个版本,但它的更高版本肯定主要是为了与 LuaJIT 一起使用而构建的。

  2. 如果您使用的是 openresty 版本,则不需要安装lua-cjson,因为它已经捆绑在一起(请参阅自述文件)

  3. 查看您收到的错误Failed fetching manifest for https://luarocks.org - Failed downloading https://luarocks.org/manifest-5.1,似乎 luarocks 无法下载清单文件,这可能是 luarocks.org 的临时问题(它对我有用,因为我正在写这个答案),或者您的网络有问题。wget尝试使用or之类的工具从错误消息中下载 URLcurl并查看它是否有效(curl甚至已安装?)


推荐阅读