This is an automated email from the ASF dual-hosted git repository.
alinsran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new d7cf12d4c add info for env var support in apisix.yaml and caution note
to export vars (#10727)
d7cf12d4c is described below
commit d7cf12d4c5d608d1b6ac36dc9aef22c74cac4897
Author: Traky Deng <[email protected]>
AuthorDate: Wed Dec 27 18:07:10 2023 -0800
add info for env var support in apisix.yaml and caution note to export vars
(#10727)
---
docs/en/latest/profile.md | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/docs/en/latest/profile.md b/docs/en/latest/profile.md
index 5c4bca679..63913a438 100644
--- a/docs/en/latest/profile.md
+++ b/docs/en/latest/profile.md
@@ -57,6 +57,12 @@ export APISIX_NODE_LISTEN=8132
export DEPLOYMENT_ADMIN_ADMIN_LISTEN=9232
```
+:::caution
+
+You should set these variables with `export`. If you do not export, APISIX
will fail to resolve for these variables.
+
+:::
+
Now when you start APISIX, it will listen on port `8132` and expose the Admin
API on port `9232`.
To use default values if no environment variables are set, you can add it to
your configuration file as shown below:
@@ -73,6 +79,30 @@ deployment:
Now if you don't specify these environment variables when running APISIX, it
will fall back to the default values and expose the Admin API on port `9180`
and listen on port `9080`.
+Similarly, you can also use environment variables in `apisix.yaml` when
deploying APISIX in standalone mode.
+
+For example, you can export the upstream address and port to environment
variables:
+
+```shell
+export HOST_ADDR=httpbin.org
+export HOST_PORT=80
+```
+
+Then create a route as such:
+
+```yaml title="apisix.yaml"
+routes:
+ -
+ uri: "/anything"
+ upstream:
+ nodes:
+ "${{HOST_ADDR}}:${{HOST_PORT}}": 1
+ type: roundrobin
+#END
+```
+
+Initialize and start APISIX in standalone mode, requests to `/anything` should
now be forwarded to `httpbin.org:80/anything`.
+
## Using the `APISIX_PROFILE` environment variable
If you have multiple configuration changes for multiple environments, it might
be better to have a different configuration file for each.