NGINX and environment variables from the configuration file

I am trying to set some environment variables in nginx through its configuration file. I am using nginx / 0.8.53 and it does not work.

server {
    listen 80;
    server_name localdictus;
    root /opt/vdmo_dictus/public;   # <--- be sure to point to 'public'!
    passenger_enabled on;
    rails_env development;
    env VDMO_MANDANT = "somevalue";
    }

This error message is:

unknown directive "env" in /opt/nginx/conf/nginx.conf:43

The documentation tells me that there is an "env" command ... so what am I doing wrong? http://wiki.nginx.org/CoreModule#env

setting environment variables through export to the shell is not an option for my application. By the way

Here are the lines:

37:    server {
38:    listen 80;
39:    server_name localdictus;
40:    root /opt/vdmo_dictus/public;   # <--- be sure to point to 'public'!
41:    passenger_enabled on;
42:    rails_env development;
43:    env VDMO_MANDANT = "somevalue";
44:    }

Hi,

Alex

+3
source share
3 answers

, , "" env - main, server. server { ... } ( ).

. . , env , .

+5

env. -E nginx:

 sudo -E /usr/local/nginx/sbin/nginx
0

rails nginx.

, RAILS_ROOT:/opt/myapp_MANDANT

MANDANT RAILS_ROOT enils .

split = RAILS_ROOT.split("_")
puts split.inspect


if split.size > 1
    ENV['VDMO_SYSTEM'] = split[2]
    ENV['VDMO_MANDANT'] = split[1]
elsif split.size > 0
    ENV['VDMO_SYSTEM'] = nil
    ENV['VDMO_MANDANT'] = split[1]
end

environment.rb .

mount -bind.

:

   mkdir railsapp_mandant
   mount -t /originalsource /railsapp_mandant

then set the public rails application path to / originalsource / public / instead of / railsapp_mandant / public /

-1
source

Source: https://habr.com/ru/post/1786403/


All Articles