.tuna.yml Reference
.tuna.yml is the project settings file. Put it at the repository root, and tuna start, traffic policies and the tuna secrets commands work the same for everyone who clones the repository. Personal settings, such as the API key or proxy, live in a different file, the global tuna.yml.
tunnels:
web:
commandLine: http 3000 --subdomain=web
tags: frontend
api:
commandLine: http 8080 --subdomain=api
tags: backend
rules:
- name: Admin only with password
expressions:
- req.URL.Path startsWith "/admin"
actions:
- type: basic_auth
config:
userList:
admin: s3cr3t
secrets:
project: api-php
config: dev
Keysβ
| Key | What it sets |
|---|---|
tunnels | Tunnels started by tuna start |
tunnels.<name>.commandLine | Command that starts the tunnel |
tunnels.<name>.tags | Tags for starting a group of tunnels |
rules | Traffic policy rules |
rules[].name | Rule name |
rules[].expressions | Conditions under which the rule applies |
rules[].actions | Rule actions |
secrets.project, secrets.config | Secrets project and config for the file's directory |
secrets.scoped | Secrets project and config for subdirectories |
1c | Platform and infobase for tuna 1c |
Where tuna looks for the fileβ
Each section is read by its own commands, and they look for the file in different places:
| Section | Read by | Where they look | Other path |
|---|---|---|---|
tunnels | tuna start, tuna service | Current directory | --tunnels-file, TUNA_START_TUNNELS_FILE |
rules | tuna http, tuna 1c | Current directory | --policy-file, TUNA_POLICY_FILE; for tuna http, also --policy-url |
secrets | tuna secrets | From the --scope directory (current by default) up to the git repository root | β |
1c | tuna 1c | Current directory | --policy-file, TUNA_POLICY_FILE |
tunnels and rules add to the sections of the same name in the global tuna.yml. A tunnel with the same name is taken from .tuna.yml; the others stay. Rules from both files run one after another: first the global ones, then those from .tuna.yml.
If there is no file, the commands work without it. If the file can't be parsed, tuna http and tuna 1c won't start the tunnel, while tuna start prints a warning and uses only the tunnels from the global tuna.yml.
tunnelsβ
| Type | Map: tunnel name β its settings |
| Read by | tuna start, tuna service |
Tunnels that tuna start runs with one command. The key is the tunnel name: you start the tunnel by it (tuna start web), and the dashboard shows it. The name must be unique within the file.
Before starting, tuna checks every tunnel in the file. If one has an error, none of them start. A tunnel that crashes restarts after 5 seconds. See the Multiple Tunnel Startup guide for details.
tunnels.<name>.commandLineβ
| Type | String |
| Required | Yes |
The command that starts the tunnel, the same as in the terminal. The tuna prefix is optional.
tunnels:
db:
commandLine: postgres 5432 --port=db --cidr-allow=203.0.113.0/24
- Supported commands:
http,tcp,ssh,app,postgres,mysql,redis,kubernetes,1c,trigger webhookandtrigger smtp. Any flags of these commands work, see the CLI reference. - The string is split into arguments on spaces; quotes are not supported. A value with a space can't be passed as a flag. Set it with an environment variable instead: tunnels inherit the environment of
tuna start. - Each tunnel gets the
TUNA_TUNNEL_NAMEvariable set to its name.
tunnels.<name>.tagsβ
| Type | String or list of strings |
| Required | No |
Tags for starting a group of tunnels: tuna start --tags=backend starts every tunnel tagged backend.
tunnels:
api:
commandLine: http 8080
tags: [backend, api]
worker:
commandLine: tcp 6379
tags: backend
rulesβ
| Type | List of rules |
| Read by | tuna http, tuna 1c |
Traffic policy rules. Rules are checked in order. A request goes through the actions of every rule whose conditions it matches.
rules[].nameβ
| Type | String |
| Required | No |
Rule name. A rule without a name is named after its position in the list.
rules[].expressionsβ
| Type | List of strings |
| Required | No |
Conditions in the exprOpens in a new tab language. The rule applies only if all conditions in the list are met. Without conditions, the actions apply to every request. For variables and functions, see Expressions.
rules:
- expressions:
- req.Method == "POST"
- req.URL.Path startsWith "/api"
actions:
- type: rate_limit
config:
rate: "60s"
capacity: 100
rules[].actionsβ
| Type | List of actions |
| Required | Yes |
What to do with the request. Actions run in order. Each action has three fields:
| Field | Required | What it sets |
|---|---|---|
type | Yes | Action type, see the table below |
config | Depends on the type | Action settings |
name | No | Action name |
type | What it does |
|---|---|
add_headers | Adds request or response headers |
remove_headers | Removes headers |
basic_auth | Asks for a username and password |
url_rewrite | Rewrites the request path |
redirect | Redirects to another URL |
deny | Rejects the request |
restrict_ips | Allows or blocks by IP address |
rate_limit | Limits the number of requests |
custom_response | Returns a predefined response |
reverse_proxy | Proxies the request to another URL |
verify_webhook | Verifies the webhook signature |
compress_response | Compresses the response |
An unknown type is a parse error, and the tunnel won't start.
secretsβ
| Type | Object with the project, config and scoped keys |
| Read by | tuna secrets |
Which secrets the tuna secrets commands use in this repository. A new developer only needs tuna login: tuna secrets run picks up the right config right away.
project and config bind the directory that contains the file:
secrets:
project: api-php
config: dev
The --project and --config flags and a personal binding from tuna secrets setup take precedence over the file. The order is described in Which binding wins.
secrets.scopedβ
| Type | Map: subdirectory path β project and config |
| Required | No |
Bindings for subdirectories, for example in a monorepo. Paths are relative to the file's directory; absolute paths and .. are errors. If several bindings match, the deepest one wins. scoped can be combined with the top-level project and config.
secrets:
project: api-php
config: dev
scoped:
frontend:
project: ui
config: dev
tuna secrets setup --local writes the binding to this section itself and leaves the rest of the file, comments included, unchanged.
The tuna.yaml file with the setup key is deprecated: the CLI warns about it and asks you to move the bindings to the secrets section of .tuna.yml.
1cβ
| Type | Object with the home, platform, name, infobase, port keys |
| Read by | tuna 1c |
The 1C:Enterprise platform and infobase that tuna 1c publishes by default. The tuna 1c setup wizard writes this section, and you can also edit it by hand.
1c:
home: 'C:\Program Files (x86)\1cv8'
platform: 'x86'
name: 'My base'
infobase: 'File="C:\Bases\MyBase";'
port: 8314
The global tuna.yml can have the same section. If both files have it, .tuna.yml overrides it entirely, and command-line arguments and flags take precedence over both files. For what each key means, see Saved settings.