I am trying to create a generic nginx.conf that does a proxy_pass depending on the environment.
I am using fixture from cloud foundry staticfile-buildpack
https://github.com/cloudfoundry/staticfile-buildpack/tree/master/fixtures/pushstate_and_proxy_pass/
I want to set a proxy pass depending on the environment variable.
This is the code of the proxy.conf:
location /api { proxy_pass {{env "MY_DEV_PROXY"}}; }
I expect that MY_DEV_PROXY environment variable that I have previously set is resolved.
Instead, when pushing my app to cloud foundry I get:
ERR 2019/02/19 08:18:39 [emerg] 88#0: directive "proxy_pass" is not terminated by ";" in /home/vcap/app/nginx/conf/includes/proxy.conf:1
When using a direct value instead of a variable:
location /api { proxy_pass https://my-dev-proxy.com; }
everything works fine.
cf curl /v2/info && cf version:
{
"description": "Cloud Foundry provided by Swisscom",
"min_cli_version": "6.42.0",
"min_recommended_cli_version": "latest",
"api_version": "2.128.0",
"osbapi_version": "2.14",
}
cf version 6.42.0+0cba12168.2019-01-10
I expect that MY_DEV_PROXY environment variable that I have previously set is resolved.-> How are you setting the environment variable? Nginx doesn't substitute the variables, but the Nginx buildpack will. It only does that during staging. Are you setting the variable so that it's set during staging when the Nginx buildpack runs? docs.cloudfoundry.org/buildpacks/nginx/#env - Daniel Mikusacf env <app>? - Daniel Mikusa