【发布时间】:2021-12-28 23:29:51
【问题描述】:
我在 nginx 中使用 lua,下面是编码字符串的代码:
set_by_lua $base64_credential '
set $es_username os.getenv("ES_USERNAME");
set $es_pwd os.getenv("ES_PWD");
return ngx.encode_base64(ngx.var.es_username+":"+ngx.var.es_pwd)
'
启动服务器后出现以下错误:
2021/11/18 01:58:01 [error] 7#7: *151 failed to load inlined Lua code: set_by_lua:2: '=' expected near '$', client: 10.0.6.61, server: localhost, request: "GET /health HTTP/1.1", host: "10.0.1.246:8080"
我使用此文档 https://github.com/openresty/lua-nginx-module#set_by_lua 中的语法,并且在设置变量时不使用 = 符号。我做错了什么?
【问题讨论】: