# 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:

```shell
tuna config save-token <your_token>

```

Set [region](https://tuna.am/en/docs/tunnels/guides/locations.md):

```shell
tuna config save-location nl

```

Set [API key](https://tuna.am/en/docs/guides/api.md):

```shell
tuna config save-api-key <your_api_key>

```

## File Example

Example of basic settings:

```yaml
---
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:

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

```

Or through the `TUNA_CONFIG` environment variable:

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

```

## Multiple Tunnel Startup

The file can store a description for [multiple tunnel startup](https://tuna.am/en/docs/tunnels/guides/multi-tunnels.md), example:

```yaml
---
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](https://tuna.am/en/docs/traffic-policy.md), example:

```yaml
---
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

```shell
tuna config check

```
