I want to pass the RAILS_ENV
env variable to nginx and use it to set the value for the rails_env
directive.
I can read the value of the variable from the environment with LUA module:
location @app { set_by_lua $env_rails_env 'return os.getenv("RAILS_ENV")'; return 200 'rails env is: ${env_rails_env}'; }
When I curl
it, I get the correct answer:
[jsosic@workstation ~]$ curl http://localhost:3005/ rails env is: development
But, if I want to use it as a value for nginx directive:
location @app { set_by_lua $env_rails_env 'return os.getenv("RAILS_ENV")'; rails_env $env_rails_env; limit_req zone=one burst=100; passenger_enabled on; }
I get the following log:
Message from application: '${env_rails_env}' database is not configured. Available: ["default", "development", "test", "production"]
Is this even possible?