Can't get environment variables in nginx, what should I do?

  • 0
    So there is a set of variables in the OS.

    ...
    export DEV1_PATH="/home/user/data/www/site.dev1"
    ...


    I'm trying to connect them to Ngixn via the perl module.

    nginx.conf
    ...
    env PATH;
    env DEV1_PATH;
    ...
    http {
      perl_set $root_path 'sub { return $ENV{"PATH"}; }';
      perl_set $dev1_path 'sub { return $ENV{"DEV1_PATH"}; }';
    }
    ....


    vhost.conf
    server {
    ...
      location /test {
        echo $root_path;
        echo $dev1_path;
      }
    ...
    }


    site.loc / test
    from nginx we get
    1) / usr / local / sbin: / usr / local / bin: / usr / sbin: / usr / bin: / sbin: / bin
    2)
    Linux Anonymous, Mar 25, 2019

  • 0 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!