How to reference OS Environment Variales in nginx.conf
agentzh
agentzh at gmail.com
Fri Sep 16 04:06:23 UTC 2011
On Fri, Sep 16, 2011 at 5:03 AM, caoxingk <nginx-forum at nginx.us> wrote:
> After set a variable by `set $name value`, i can reference it like
> `$name`,
> but when i export a OS Environment Variale by `env name_from_env`, like
> http://wiki.nginx.org/CoreModule#env said,
> and i am sure the name_from_env is valid which defined form nginx's
> parent process.
>
> But, my friends, how to reference it ?
You can read system environment variables with ngx_lua enabled in your
nginx build: http://wiki.nginx.org/HttpLuaModule
env PATH;
http {
...
server {
location /path {
set_by_lua $path 'return os.getenv("PATH")';
...
}
}
BTW, to use the set_by_lua directive, you also need to enable the
ngx_devel_kit module here: https://github.com/simpl/ngx_devel_kit
(it'll be easier if you use the ngx_openresty bundle).
Regards,
-agentzh
More information about the nginx
mailing list