markokocic commented on issue #10530:
URL: https://github.com/apache/apisix/issues/10530#issuecomment-1875368071
hi @kayx23 here's my setup full example. I think we are a bit closer to
finding out the underlying problem.
docker-compose-standalone.yml:
```
version: "3"
services:
apisix:
image: apache/apisix:${APISIX_IMAGE_TAG:-3.7.0-debian}
restart: always
volumes:
-
./apisix_conf/apisix-standalone.yaml:/usr/local/apisix/conf/apisix.yaml:ro
environment:
- APISIX_STAND_ALONE=true
- EP_MYHOST_1=b92.net
- EP_MYHOST_2=blic.rs
ports:
- "9180:9180/tcp"
- "9080:9080/tcp"
- "9091:9091/tcp"
- "9443:9443/tcp"
- "9092:9092/tcp"
networks:
apisix:
web1:
image: nginx:1.19.0-alpine
restart: always
volumes:
- ./upstream/web1.conf:/etc/nginx/nginx.conf
ports:
- "9081:80/tcp"
environment:
- NGINX_PORT=80
networks:
apisix:
networks:
apisix:
driver: bridge
```
apisix_conf/apisix-standalone.yaml:
```
routes:
- uri: /b92/*
upstream:
nodes:
"${{EP_MYHOST_1:=}}:443": 1
type: roundrobin
scheme: https
#END
```
As you can see, I defined EP_MYHOST_1 and EP_MYHOST_2 environment variables
in a standard docker way.
After that, I started docker with `docker compose -f
docker-compose-standalone.yml up -d`
When I ran the following right after starting docker, I got success:
```
curl http://localhost:9080/b92/index.html -v
```
However, if I after that change the config file to use EP_MYHOST_2 instead
of EP_MYHOST_1 like so:
```
routes:
- uri: /b92/*
upstream:
nodes:
"${{EP_MYHOST_2:=}}:443": 1
type: roundrobin
scheme: https
#END
```
the config gets reloaded successfully, but the environment variable can't be
resolved any more, although it is properly defined. If I edit it back to
EP_MYHOST_1, it works again.
Looks like something gets wrong after reloading the config file. It seems
like it can resolve env variables only if they are present in that file from
the beginning, making the whole config reload feature confusing and not
practical.
At the beginning, I was thinking environment variable resolution didn't work
at all because I was starting with the empty config file and editing and
reloading it incrementally, thinking it wouldn't matter if the variable was
there from the start or not.
cc: @shreemaan-abhishek , @hanqingwu
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]