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

Some settings can be defined with special commands:

Save token:

tuna config save-token <your_token>

Set region:

tuna config save-location nl

Set API key:

tuna config save-api-key <your_api_key>

File Example

Example of basic settings:

---
version: "1"
token: tt_***
apiKey: tak_***
location: nl
inspectAddr: "0.0.0.0"

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"

Checking Syntax Correctness

tuna config check