Functions
Helpful functions you can use to optimize your configuration files.
HCL supports functions that can be used to generate values in the configuration file. The following functions are supported:
num_cpus
Returns the number of CPUs (logical cores) available on the system.
env
You can use the env function to retrieve environment variables during the configuration parsing process of Proksi.
This is particularly useful if you have secrets or other type of data that you do not want to be part of your git
or repository:
Usage
env(NAME: string)
where NAME is an environment variable present during Proksi's run.
Errors
This function will throw an error if the environment variable is not set.
import
Configuring Proksi in one single file is a no-brainer, but it works well only when you don't have hundreds of upstreams, routes, headers and reusable pieces that you want to commit or have others work on them too.
The import
function is a way to help improve your configuration organization in the long term.
Usage
import(RELATIVE_PATH: string)
where relative_path is always a path relative to the main configuration file (not relative to other imports).
The reason the piece above is highlighted is because you can use import
within import
s and at the end what Proksi does is include them all together, so it needs to find them relative to itself.
And then, a ./sites/my-site.com
will look like this:
Last updated