markokocic commented on issue #10509:
URL: https://github.com/apache/apisix/issues/10509#issuecomment-1820482197
hi @kayx23
I just tested again before updating the docs, and it looks that environment
variable substitution is indeed not supported in standalone `apisix.yaml`
I craeted the following route:
```yaml
- uri: /b92/*
upstream:
nodes:
"${{EP_MYHOST_1:=}}:443": 1
type: roundrobin
scheme: https
```
and configured EP_MYHOST_1 environment variable in docker compose file by
adding:
```yaml
environment:
- EP_MYHOST_1=b92.net
```
I then started the container and logged in to the running container to
confirm:
```shell
apisix@e9512d0cfdaa:/usr/local/apisix$ echo $EP_MYHOST_1
b92.net
```
However, when I try to access the route, I get the following response:
```shell
C:\Users\Marko.Kocic>curl http://localhost:9080/b92/
<html>
<head><title>503 Service Temporarily Unavailable</title></head>
<body>
<center><h1>503 Service Temporarily Unavailable</h1></center>
<hr><center>openresty</center>
<p><em>Powered by <a
href="https://apisix.apache.org/">APISIX</a>.</em></p></body>
</html>
```
Apisix logs also shows the same error:
```
2023/11/21 08:39:25 [error] 38#38: *6194 [lua] upstream.lua:79:
parse_domain_for_nodes(): dns resolver domain: ${{EP_MYHOST_1:=}}:443 error:
failed to query the DNS server: dns server error: 3 name error, client:
10.89.0.7, server: _, request: "GET /b92/ HTTP/1.1", host: "localhost:9080"
2023/11/21 08:39:25 [error] 38#38: *6194 [lua] resolver.lua:80:
parse_domain(): failed to parse domain: , error: failed to query the DNS
server: dns server error: 3 name error, client: 10.89.0.7, server: _, request:
"GET /b92/ HTTP/1.1", host: "localhost:9080"
2023/11/21 08:39:25 [error] 38#38: *6194 [lua] upstream.lua:79:
parse_domain_for_nodes(): dns resolver domain: error: failed to query the DNS
server: dns server error: 3 name error, client: 10.89.0.7, server: _, request:
"GET /b92/ HTTP/1.1", host: "localhost:9080"
2023/11/21 08:39:25 [error] 38#38: *6194 [lua] init.lua:551:
handle_upstream(): failed to set upstream: no valid upstream node, client:
10.89.0.7, server: _, request: "GET /b92/ HTTP/1.1", host: "localhost:9080"
10.89.0.7 - - [21/Nov/2023:08:39:25 +0000] localhost:9080 "GET /b92/
HTTP/1.1" 503 269 0.522 "-" "curl/8.4.0" - - - "http://localhost:9080"
```
However, when I update apisix.yml file to use host name instead of a
variable, everything works ok.
At this point, I tend to believe that the documentation is correct that it
doesn't mention apisix.yml supporting environment variable substitution. Maybe
it should be explicit about not supporting, since initially, I also wrongly
believed that it should support it.
Or a feat ticket should be created to enable this support in apisix.yml.
--
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]