Skip to main content

.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.

.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​

KeyWhat it sets
tunnelsTunnels started by tuna start
tunnels.<name>.commandLineCommand that starts the tunnel
tunnels.<name>.tagsTags for starting a group of tunnels
rulesTraffic policy rules
rules[].nameRule name
rules[].expressionsConditions under which the rule applies
rules[].actionsRule actions
secrets.project, secrets.configSecrets project and config for the file's directory
secrets.scopedSecrets project and config for subdirectories
1cPlatform 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:

SectionRead byWhere they lookOther path
tunnelstuna start, tuna serviceCurrent directory--tunnels-file, TUNA_START_TUNNELS_FILE
rulestuna http, tuna 1cCurrent directory--policy-file, TUNA_POLICY_FILE; for tuna http, also --policy-url
secretstuna secretsFrom the --scope directory (current by default) up to the git repository rootβ€”
1ctuna 1cCurrent 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​

TypeMap: tunnel name β†’ its settings
Read bytuna 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​

TypeString
RequiredYes

The command that starts the tunnel, the same as in the terminal. The tuna prefix is optional.

.tuna.yml
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 webhook and trigger 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_NAME variable set to its name.

tunnels.<name>.tags​

TypeString or list of strings
RequiredNo

Tags for starting a group of tunnels: tuna start --tags=backend starts every tunnel tagged backend.

.tuna.yml
tunnels:
api:
commandLine: http 8080
tags: [backend, api]
worker:
commandLine: tcp 6379
tags: backend

rules​

Available on the Pro and Legend plans
TypeList of rules
Read bytuna 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​

TypeString
RequiredNo

Rule name. A rule without a name is named after its position in the list.

rules[].expressions​

TypeList of strings
RequiredNo

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.

.tuna.yml
rules:
- expressions:
- req.Method == "POST"
- req.URL.Path startsWith "/api"
actions:
- type: rate_limit
config:
rate: "60s"
capacity: 100

rules[].actions​

TypeList of actions
RequiredYes

What to do with the request. Actions run in order. Each action has three fields:

FieldRequiredWhat it sets
typeYesAction type, see the table below
configDepends on the typeAction settings
nameNoAction name
typeWhat it does
add_headersAdds request or response headers
remove_headersRemoves headers
basic_authAsks for a username and password
url_rewriteRewrites the request path
redirectRedirects to another URL
denyRejects the request
restrict_ipsAllows or blocks by IP address
rate_limitLimits the number of requests
custom_responseReturns a predefined response
reverse_proxyProxies the request to another URL
verify_webhookVerifies the webhook signature
compress_responseCompresses the response

An unknown type is a parse error, and the tunnel won't start.

secrets​

TypeObject with the project, config and scoped keys
Read bytuna 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:

.tuna.yml
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​

TypeMap: subdirectory path β†’ project and config
RequiredNo

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.

.tuna.yml
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​

TypeObject with the home, platform, name, infobase, port keys
Read bytuna 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.

.tuna.yml
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.