这个问题已经解决了,
默认nginx会屏蔽掉启动时的环境变量,如果需要lua读取环境变量,需要在nginx.conf加上
env TEST;
On Monday, August 8, 2016 at 11:17:09 PM UTC+8, Xiangjun Zhang wrote:
config
```
# cat test.conf
server {
listen 80;
server_name localhost;
location / {
default_type text/plain;
content_by_lua_file app/ip.lua;
}
}
```
start command
```
# TEST=foobar nginx
```
lua code
```
# cat app/ip.lua
ngx.say(os.getenv(TEST))
```
curl test
```
# curl localhost:8080
nil
```