Skip to main content

Environment Variables

List of environment variables supported by the tuna client.

Global

NameDescription
TUNA_CONFIGPath to the configuration file
TUNA_LOGPath to the log file: /file/to/file.log, stdout, stderr (default "stdout")
TUNA_LOG_LEVELLogging level: debug, info, warn, error, fatal (default "info")
TUNA_LOG_FORMATLogging format: text, json (default "text")

Common

NameDescription
TUNA_PORTPort or destination address (e.g., 8080 or 10.0.0.10:5432)
TUNA_TOKENToken for creating a tunnel
TUNA_LOCATIONConnection region (nl or ru)
TUNA_API_KEYAPI key

For HTTP tunnels

NameDescription
TUNA_BASIC_AUTHAdd basic authentication (e.g., user:pass)
TUNA_CIDR_ALLOWReject connections that do not match the specified CIDR
TUNA_CIDR_DENYReject connections that match the specified CIDR
TUNA_CORSEnable CORS headers and automatic OPTIONS request handling
TUNA_DOMAINReserved domain
TUNA_FILE_SERVERPath to directory for publishing files via HTTP
TUNA_FILE_SERVER_SPAPath to directory for publishing SPA site
TUNA_HTTPS_REDIRECTRedirect requests to HTTPS (true or false)
TUNA_INSPECTEnable or disable request inspector (true or false)
TUNA_INSPECT_ADDRSet address for the request inspector
TUNA_KEY_AUTHAdd authentication key passed in X-Token header
TUNA_POLICY_FILEPath to configuration file with rules (default .tuna.yml)
TUNA_QR_CODEGenerate and display QR code
TUNA_RATE_LIMITLimit the number of requests to your application (e.g., 20 for 20 requests/sec)
TUNA_REQUEST_HEADERAdd headers to pass to local service (e.g., host:tuna.am)
TUNA_RESPONSE_HEADERAdd headers to pass to client (e.g., env:test)
TUNA_SUBDOMAINReserved subdomain
TUNA_TLS_SKIP_VERIFYSkip TLS verification
TUNA_VERIFY_WEBHOOKVerify if webhooks are signed by this provider (e.g., gitlab)
TUNA_VERIFY_WEBHOOK_SECRETSecret used by the provider to sign webhooks, if any
TUNA_WEBDAVPath to directory for publishing files via WebDAV

For TCP tunnels

NameDescription
TUNA_TCP_PORTReserved port number or alias
TUNA_QR_CODEGenerate and display QR code
TUNA_CIDR_ALLOWReject connections that do not match the specified CIDR
TUNA_CIDR_DENYReject connections that match the specified CIDR

For SSH tunnels

NameDescription
TUNA_TCP_PORTReserved port number or alias
TUNA_SSH_AUTHSet static username/password
TUNA_SSH_PASSWORD_AUTHEnable or disable login/password authentication
TUNA_RECORD_SESSIONSSH session recording
TUNA_CIDR_ALLOWReject connections that do not match the specified CIDR
TUNA_CIDR_DENYReject connections that match the specified CIDR

For TRIGGER tunnels

NameDescription
TUNA_TCP_PORTReserved port number or alias
TUNA_TRIGGER_SMTP_USERNAMEUsername for SMTP connection
TUNA_TRIGGER_SMTP_PASSWORDUser password for SMTP connection
TUNA_TRIGGER_WEBHOOK_SECRETSecret to be verified against X-Webhook-Secret header value

For Postgres/Redis tunnels

NameDescription
TUNA_TCP_PORTReserved port number or alias
TUNA_QR_CODEGenerate and display QR code
TUNA_INSPECTEnable or disable request inspector (true or false)
TUNA_INSPECT_ADDRSet address for the request inspector
TUNA_CIDR_ALLOWReject connections that do not match the specified CIDR
TUNA_CIDR_DENYReject connections that match the specified CIDR

Service creation and management

NameDescription
TUNA_SERVICE_NAMEService name
TUNA_SERVICE_INSTALL_USERUser under which the service will run
TUNA_SERVICE_INSTALL_PASSWORDPassword when specifying a different user (Windows only)

Multiple tunnel startup

NameDescription
TUNA_START_TUNNELS_FILEPath to configuration file with tunnels (default .tuna.yml)
TUNA_STARTTunnel name to start
TUNA_START_TAGSTunnel tags to start
TUNA_START_ALLStart all tunnels

Port detection

NameDescription
TUNA_DETECT_SECONDSTime interval allocated for port detection

Secrets

NameDescription
TUNA_SECRETS_SCOPEDirectory configuration for scope (default .)
TUNA_SECRETS_PROJECTProject alias
TUNA_SECRETS_CONFIGConfiguration alias
TUNA_SECRETS_FORMATOutput format (json, yaml or env) (default json)
TUNA_SECRETS_NO_FILEPrint to stdout (default false)
TUNA_SECRETS_WATCHAutomatically restart process when secrets change (default false)

Working with direnv

direnv is an environment variable manager for the terminal. It allows you to automatically load and unload environment variables depending on the current directory – this allows you to have environment variables specific to each project you work on.

Before each prompt, direnv checks for the presence of a .envrc file in the current and parent directories, and if the file exists, it is loaded into a bash subshell, and all exported variables are then captured by direnv and become available to the shell.

Before using direnv, you need to install it. Installation instructions are available in the official documentation. After that, create a .envrc file in your project directory with tuna settings, for example:

export TUNA_PORT=8080
export TUNA_SUBDOMAIN=my-project

When navigating to the project directory and running the tuna http command, a tunnel will be created with the settings from the .envrc file:

% tuna http
INFO[13:00:00] Welcome to Tuna
INFO[13:00:00] Account: test (Paid till 05.04.2024)
INFO[13:00:00] Web Interface: http://127.0.0.1:4040
INFO[13:00:00] Forwarding https://my-project.ru.tuna.am -> 127.0.0.1:8080