Using ENV vars on fortrabbit

Manage environment variables with the fortrabbit dashboard.

Log in to see the link here.

The input supports the dotenv file format and allows you to create or update multiple variables at once. The changes will be distributed after you save the page. That may take around 60 seconds.

# ENV var types on fortrabbit

There are four different kinds of ENV vars here on fortrabbit which are available to your environment at runtime.

# Software template ENV vars

Depending on the detected or chosen software, additional ENV vars will be seeded for you. This selection will configure the server ENV vars in ways, the software can work with it. For example, for Laravel and Craft, an ENV var like DB_PASSWORD will be populated with the password of the database. So, most likely, your fortrabbit environment will work out of the box. As a bonus you even reset the database password without touching any configurations.

# System ENV vars

System ENV vars are automatically updated values that contain access details for services offered by fortrabbit. For example:

MY_MYSQL=${FORTRABBIT_MYSQL_PASSWORD}
# MY_SQL is the key
# ${FORTRABBIT_MYSQL_PASSWORD} is an alias for a value populated by fortrabbit
apache

System ENV vars will not overwrite existing, manually created ENV vars. This means: if you manually create an ENV var, we guarantee that we won't replace it's value by a dynamically generated ENV var.

# Custom ENV vars

Those are the ones you add yourself in the dashboard.

# Nested ENV vars

You can use simple, nested variables in your custom ENV vars. Simple means, that you can set variables which reference other variables, which contain a value, for example:

# will work:
OTHER_VAR=something
MY_VAR=${OTHER_VAR}
apache

Order matters. First define something before referencing. Multiple levels of interpolation are not supported. That means that you cannot use variables, which reference other variables, which again reference other variables, for example:

# will not work:
MY_VAR=${OTHER_VAR}
OTHER_VAR=${ANOTHER_VAR}
ANOTHER_VAR=something
apache

# ENV var validation

Strict validation rules for ENV vars are in use in the dashboard while entering. Chars like the "$" sign can be harmful in Linux systems. Here is the regex we use to validate the ENV var input in the dashboard:

/^[\p{L}\p{N}\ _\-\+=\.,:;\?!@~%&\*\(\)\[\]\{\}<>\/\\#]+$/u
raw

So sometimes, when you want to store an external API key as an ENV var, you might get a validation error like: "Variable value contains invalid characters". If you can not change the value of your ENV var, you can encode and decode those:

# Reserved environment variable names

There are some names you can not use here:

, __FRBIT__, argc, argv, AUTHTYPE, CHARSET, CONTEXT_DOCUMENT_ROOT, CONTEXT_PREFIX, DOCUMENT_ROOT, FCGI_ROLE, FORTRABBIT, GATEWAYINTERFACE, GROUP, HOME, HTTP_, HTTPS, LANG, LC__, LOGNAME, MAIL, MUSL_LOCPATH, OLDPWD, ORIG_PATH_INFO, PAGER, PATH, PATH_INFO, PATH_TRANSLATED, PHP_AUTH_DIGEST, PHP_AUTH_PW, PHP_AUTH_USER, PHP_SELF, PS0, PS1, PS2, PS3, PS4, PWD, QUERY_STRING, REDIRECT_REMOTE_USER, REMOTE_ADDR, REMOTE_HOST, REMOTE_PORT, REMOTE_USER, REQUEST_METHOD, REQUEST_SCHEME, REQUEST_TIME, REQUEST_TIME_FLOAT, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME, SCRIPT_URI, SCRIPT_URL, SERVER_ADDR, SERVER_ADMIN, SERVER_NAME, SERVER_PORT, SERVER_PROTOCOL, SERVER_SIGNATURE, SERVER_SOFTWARE, SHELL, SHLVL, SSH_CLIENT, SSH_CONNECTION, SSH_TTY, TERM, USER

Found a tpyo?Edit