Set proxy_pass from enviroment variable when starting container (nginx) #613
Replies: 2 comments
-
Maybe try something like: https://github.com/jwilder/nginx-proxy/blob/master/nginx.tmpl#L102 |
Beta Was this translation helpful? Give feedback.
-
Hi @jwilder took me a while to look at this again, so that looks like it would do the trick, however, in the nginx.tmpl file that comes with the nginx generator, it starts with this line:
Any ideas why it works in the |
Beta Was this translation helpful? Give feedback.
-
I need to set the proxy_pass in the template depending on whether an enviroment variable is set.
The problem i am having is I need to access the current
$container
object to get at the.Env
object so I can access the enviroment variables. When you generate theserver {}
block in your nginx template, you are doing it outside of the loop that accesses the contents of each container, as you just need the host:If I have an enviroment variable that is set when a container is run called PROXY_PASS, how can I check whether that is set, and if so set the proxy_pass to that, otherwise set it to
$host
?I tried the following:
Which works, however it prints out as many lines as there are containers (in this case just a comment to test if that works).
Beta Was this translation helpful? Give feedback.
All reactions