Answer the question
In order to leave comments, you need to log in
How to beat passing variables to nginx config from ConfigMap with env variables to set upstream forwarding between services?
Probably too smart with the title, but I'll try to fix it in the description.
There are 2 services. One frontend with react+nginx that handles non-root requests a la "domain.ru/cabinet", there is a second worpress service with php-fpm that handles root requests.
Everything works in containers and was launched with docker-compose. Separation of the monolith and communication between containers was defined as an nginx setting:
set $front_react frontend_${BRANCH_NAME}_react_nginx;
location ~ \.html$ {
proxy_pass http://$front_react;
}
nginx: [emerg] unknown "branch_name" variable
COPY default.conf /etc/nginx/conf.d/default.conf
data:
BRANCH_NAME: pp-3223
default.conf: |
server { ....
}
Answer the question
In order to leave comments, you need to log in
Yes, the variable does need to be defined. You can define it by means of changing it server_name
to a regular expression with named groups:
# это пример регулярку надо поменять под свои нужды
server_name ~(?<branch_name>[^\.]*)\.(?<tld>[^\.]*)$;
location ~ \.html$ {
proxy_pass http://frontend_${branch_name}_react_nginx;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question