Skip to main content

Configuration File

Some basic settings can be set through a configuration file in yaml format.

Default Path​

On Windows, the file is usually stored at - $env:USERPROFILE\AppData\Local\tuna\tuna.yml, on Unix-like operating systems (macOS, Linux, FreeBSD) - ${HOME}/.config/tuna/tuna.yml.

Saving Basic Settings​

The session you get with tuna login isn't stored in this file but in the system keyring (see Authorization). Only an API key goes into the file.

Save an API key:

tuna config save-api-key <your_api_key>

tuna login --with-api-key does the same, but reads the key from standard input, so it doesn't stay in the shell history.

Deprecated commands

Since tuna-cli 0.39, tuna config save-token and tuna config save-location are deprecated and hidden from the help. The token field in the file still works, but the CLI warns you to replace it: log in with tuna login or save an API key. The location field is only needed for names reserved in the ru and nl zones — see Regions.

The inspectAddr field is no longer read: the CLI warns about it in the log. Set the inspector address with TUNA_INSPECT_ADDR and the port with --inspect-port, see the inspector page.

File Example​

Example of basic settings:

---
version: "1"
apiKey: tak_***

If the only way out to the internet is a SOCKS5 proxy, add the proxy: socks5://host:port key. See Connecting through a SOCKS5 proxy.

Using a Different File Path​

You can explicitly specify the path to the file using the --config flag:

tuna --config /tmp/tuna.yml http 8080

Or through the TUNA_CONFIG environment variable:

export TUNA_CONFIG=/tmp/tuna.yml
tuna http 8080

Multiple Tunnel Startup​

The file can store a description for multiple tunnel startup, example:

---
tunnels:
web:
tags: [frontend, ui]
commandLine: tuna http localhost:5173 --subdomain=web
php:
tags: [backend, php, api]
commandLine: tuna http 8080 --subdomain=api
python:
tags: [backend, python, api]
commandLine: tuna http 9000 --subdomain=new-api
postgres:
tags: db
commandLine: tuna tcp 5432 --port=postgres
mysql:
tags: db
commandLine: tuna tcp 3306 --port=mysql

Traffic Policies​

The file can store rule descriptions for traffic policies, example:

---
rules:
- name: robots.txt
expressions:
- hasPrefix(req.URL.Path, "/robots.txt")
actions:
- name: step 1
type: custom_response
config:
statusCode: 200
content: |
User-agent: *
Disallow: /
headers:
content-type: "text/plain"
- name: Mock for banks
expressions:
- hasPrefix(req.URL.Path, "/banks")
actions:
- type: custom_response
config:
statusCode: 403
content: |
Forbidden
headers:
content-type: "text/plain; charset=utf-8"
- expressions:
- hasPrefix(req.URL.Path, "/v1")
actions:
- type: reverse_proxy
config:
url: "http://127.0.0.1:7070"

Secrets Binding​

The secrets.scoped section holds personal bindings of directories to secrets projects and configs, written by tuna secrets setup. A binding shared by the whole repository goes into the project's .tuna.yml, see The secrets section in .tuna.yml.

Checking Syntax Correctness​

tuna config check