【问题标题】:NGINX lua use secure_link_md5 from env varNGINX lua 使用来自 env var 的 secure_link_md5
【发布时间】:2020-04-27 01:01:33
【问题描述】:

我正在使用支持 lua 的 NGINX 从我的 .env 文件中访问主机名和其他与应用程序相关的变量。 现在我想使用secure_link_md5 var。来自 .env 文件,但我不明白如何将字符串放在一起以便 nginx 可以理解。

这是我的 nginx 配置的样子:

env LINK_SECRET;

set_by_lua $curr_dl_link_secret 'return os.getenv("LINK_SECRET")'; # Needs to be set correctly
secure_link_md5 = "${curr_dl_link_secret}$uri$secure_link_expires";

通常我会在不使用 lua 和 env vars 的情况下设置配置行:

secure_link_md5 "XGc7YyXERjiSvs4PtzpnBMANuFd22VAmXDc66g6JU$uri$secure_link_expires";

目前NGINX总是返回如下错误:

“secure_link_md5”中的参数数量无效

【问题讨论】:

    标签: nginx lua environment-variables


    【解决方案1】:

    NGINX 将“=”视为参数。我不熟悉 lua 的 NGINX,但我认为“{}”也是不必要的。

    我猜你想要这样的东西:

    secure_link_md5 "$curr_dl_link_secret$uri$secure_link_expires";
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-07
      • 2020-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-28
      • 1970-01-01
      • 2015-11-18
      相关资源
      最近更新 更多