# Routes

A route is a path from the input ([Listen](https://flying-fish.gitbook.io/flyingfish/index/configurations/listen)) to the destination. The destination can be of different types, stream, HTTP/HTTPS, SSH, use.

With the help of the [graphic from Listen](https://flying-fish.gitbook.io/flyingfish/index/listen#listen-flow) I would like to show the area controlled by the route again:

<figure><img src="https://1973811904-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Flk5l3lUfuUzRDnMDVwnw%2Fuploads%2F8sNiLAU1hcLqRfKUhE2I%2Froutes_listenflow.png?alt=media&#x26;token=6cdf1452-0fbb-41bf-8f93-deb20523d3bd" alt=""><figcaption><p>Listen and Routes</p></figcaption></figure>

## Routes List

<figure><img src="https://1973811904-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Flk5l3lUfuUzRDnMDVwnw%2Fuploads%2FGiaRXAtNszDrGQq8D5q5%2Froutes_list.png?alt=media&#x26;token=deb1eaba-accd-4862-9125-b8cd3350d720" alt=""><figcaption><p>Routes list</p></figcaption></figure>

1. The new creation and loading of the configuration of the nginx (all Listen, Routes, etc.) can be triggered again manually at any time.

{% hint style="info" %}
Existing connections are kept as if running the command: nginx -s reload
{% endhint %}

2. The first thing to see in the Routes list are the default routes. If no route is specified, the default routes always apply.
3. Each domain entered in [Domains](https://flying-fish.gitbook.io/flyingfish/index/configurations/domains) is displayed under Routes. One or more routes from one or more [Listen](https://flying-fish.gitbook.io/flyingfish/index/configurations/listen) to a destination can now be entered.

<figure><img src="https://1973811904-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Flk5l3lUfuUzRDnMDVwnw%2Fuploads%2FFwNWvx03IKgF3ROLB416%2F7zwwhv.jpg?alt=media&#x26;token=c36a3436-0c14-4f0c-8b67-7b8aff845ae0" alt=""><figcaption><p>Generate by <a href="https://imgflip.com/i/7zwwhv">https://imgflip.com/i/7zwwhv</a></p></figcaption></figure>

## Default Routes

<figure><img src="https://1973811904-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Flk5l3lUfuUzRDnMDVwnw%2Fuploads%2FZJ8ypjXOZgqefEQcsmEt%2Froutes_defaults.png?alt=media&#x26;token=aa875dec-18b5-4129-93e7-27712c1560a4" alt=""><figcaption><p>Default routes</p></figcaption></figure>

The default Routes are installed at the beginning of the [setup](https://flying-fish.gitbook.io/flyingfish/index/installation). These routes are the default path if no domain or protocol split takes effect beforehand.

{% hint style="info" %}
The default routes cannot be edited or deleted.
{% endhint %}

1. The <mark style="background-color:orange;">listen stream on port 53</mark> points to FlyingFish's internal <mark style="background-color:red;">DNS server</mark> (this lists on port 5333 so that nginx can get port 53).&#x20;
2. The <mark style="background-color:orange;">listen stream on port 443</mark> points to the internal <mark style="background-color:green;">HTTPS service</mark> with port 10443. HTTPS connections are handled with certificates.
3. The <mark style="background-color:orange;">listen stream on port 80</mark> points to the internal <mark style="background-color:green;">HTTP service</mark>, no encryption with a certificate is used.&#x20;

{% hint style="info" %}
If set for [listening](https://flying-fish.gitbook.io/flyingfish/index/configurations/listen), the [IP access blacklist/whitelist](https://flying-fish.gitbook.io/flyingfish/index/configurations/listen/ip-access) takes effect.
{% endhint %}

The yellow "<mark style="background-color:yellow;">P</mark>" can also be seen on point <mark style="color:red;">2</mark> and <mark style="color:red;">3</mark>. It indicates that the connection with [Proxy protocol](https://flying-fish.gitbook.io/flyingfish/index/configurations/listen/proxy-protocol) is activated. On the target side you can see the "<mark style="background-color:yellow;">P</mark>" with an arrow pointing down. It shows that the [Proxy protocol](https://flying-fish.gitbook.io/flyingfish/index/configurations/listen/proxy-protocol) is removed again.

{% hint style="info" %}
If no P with an arrow appears at the destination, the [Proxy protocol](https://flying-fish.gitbook.io/flyingfish/index/configurations/listen/proxy-protocol) will be passed on to the remote server! This remote server must expect the [Proxy protocol](https://flying-fish.gitbook.io/flyingfish/index/configurations/listen/proxy-protocol), otherwise it will not understand this connection!
{% endhint %}

## Add Stream/Route

<figure><img src="https://1973811904-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Flk5l3lUfuUzRDnMDVwnw%2Fuploads%2FgQDAGo6a7ksLXRt1qwHc%2Froutes_add.png?alt=media&#x26;token=04084e5a-e57b-4862-a0ce-cf458937b67c" alt=""><figcaption><p>Routes list, example domains</p></figcaption></figure>

1. If the two domains <mark style="background-color:purple;">example.com</mark> and <mark style="background-color:purple;">sub1.example.com</mark> are created under [Domains](https://flying-fish.gitbook.io/flyingfish/index/configurations/domains), we can now see them in Routes.
2. Adding a <mark style="background-color:orange;">Stream</mark> or <mark style="background-color:green;">HTTP/HTTP</mark>s route can be clicked in the context menu on the right, per domain. A domain can have multiple <mark style="background-color:orange;">Streams</mark> or <mark style="background-color:green;">HTTP/HTTP</mark>s routes.

## Add Stream

<figure><img src="https://1973811904-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Flk5l3lUfuUzRDnMDVwnw%2Fuploads%2FnpwBImsIzi7bFSlqbD4V%2Froutes_add_stream.png?alt=media&#x26;token=6b9c13c1-9930-4796-81eb-fcb0b59fe757" alt=""><figcaption><p>Stream dialog</p></figcaption></figure>

1. **Tabs**: The tabs offer targeted setting options for the stream. Depending on the destination type (6.), the tabs expand with more setting options.
2. **Domain Name/IP**: Here we can see again which domain we are adding the stream to.
3. **Listen**: Which [Listen](https://flying-fish.gitbook.io/flyingfish/index/configurations/listen) entry our route accesses/acts to can be selected here.
4. **Index**: The index indicates the order in which our routes are sorted. 0 would come first, with all higher numbers following downwards. This may be necessary if a route has a higher priority. If there is no priority, this field can be left empty.
5. **Alias-Name (Intern)**: A name used internally in the Nginx config. The name helps when checking the config. But can be left empty because it is generated automatically.
6. **Destination-Type**: The type of target changes depending on the selection above the tab (under 1.) with further settings.

### Stream Destination-Type

<figure><img src="https://1973811904-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Flk5l3lUfuUzRDnMDVwnw%2Fuploads%2FyukqBEfugxCm5ioEbNfE%2Froutes_add_stream_types.png?alt=media&#x26;token=f09900c5-094a-478d-b808-dfacaaa898c2" alt=""><figcaption></figcaption></figure>

#### <mark style="background-color:orange;">IP/Host direct (Stream)</mark>

<figure><img src="https://1973811904-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Flk5l3lUfuUzRDnMDVwnw%2Fuploads%2FjOGRxZyohUxenwWfiNCN%2Froutes_add_stream_upstream.png?alt=media&#x26;token=80fe582c-de15-4b2c-aaa5-3f523ce966cb" alt=""><figcaption></figcaption></figure>

1. IP/Host direct (Stream) adds a new tab where upstreams can be added.
2. An upstream can be added here.

<figure><img src="https://1973811904-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Flk5l3lUfuUzRDnMDVwnw%2Fuploads%2FGmGIuN6CYfcRUpXRrvIE%2Froutes_add_stream_upstream_add.png?alt=media&#x26;token=70b3916c-f0f4-4823-aa3e-cafbe5aa7443" alt=""><figcaption><p>Stream Dialog with upstreams</p></figcaption></figure>

1. **#**: ID of the upstream, purely informative
2. Deletes the upstream entry.
3. **Address**: Destination IP address to which the requests are forwarded.
4. **Port**: Specification of which port the destination has.
5. **Proxy protocol out**: Activation removes the [Proxy protocol](https://flying-fish.gitbook.io/flyingfish/index/configurations/listen/proxy-protocol) header. In the routes list it is indicated with "<mark style="background-color:yellow;">P</mark>".
6. The second upstream added as an example. If upstream 1 with IP 192.168.178.1 cannot be reached, upstream 2 with IP 192.168.178.2 is used.

<figure><img src="https://1973811904-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Flk5l3lUfuUzRDnMDVwnw%2Fuploads%2F00JCRREeb35nNXs66zH8%2Froutes_add_stream_upstream_list.png?alt=media&#x26;token=a1659036-b9cd-4434-875a-541fa922d8f7" alt=""><figcaption><p>I have activated the upstream 192.168.178.1 proxy protocol out.</p></figcaption></figure>

#### <mark style="background-color:green;">Intern Listen</mark>

<figure><img src="https://1973811904-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Flk5l3lUfuUzRDnMDVwnw%2Fuploads%2Fr21ZOVtiw8rYL0YCGywl%2Froutes_add_stream_listen_add.png?alt=media&#x26;token=6b887ab5-77e1-4332-8f5e-b8e47f35a6a7" alt=""><figcaption></figcaption></figure>

1. The destination type <mark style="background-color:green;">Intern Listen (Http/Https)</mark> adds the Listen tab.
2. The [Listen](https://flying-fish.gitbook.io/flyingfish/index/configurations/listen) for Internal are now available for selection.

{% hint style="info" %}
It only makes sense to set this internal listen in the stream if you have added a new custom internal listen (Http/Https) service under [Listen](https://flying-fish.gitbook.io/flyingfish/index/configurations/listen), deviating from the already supplied 10443 port or 10080 port. If you remember, there are [default routes](#default-routes) that take the path from the stream to HTTP/HTTPs from port 443 and 80. Therefore, you do not have to specify this path yourself!
{% endhint %}

## Add HTTP/HTTPS
