Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCP redirection guide #360

Merged
merged 11 commits into from
Aug 26, 2024
4 changes: 2 additions & 2 deletions .github/workflows/review-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ jobs:
ORGA_ID: ${{ secrets.ORGA_ID }}
GH_CC_PRE_BUILD_HOOK: './clevercloud-deploy-script.sh'
GH_CC_WEBROOT: '/public'
GH_HEXTRA_VERSION: '0.8.0'
GH_HEXTRA_VERSION: 'v0.8.2'
GH_HUGO_ENV: 'production'
GH_HUGO_VERSION: '0.129.0'
GH_HUGO_VERSION: '0.133.0'
with:
type: 'static-apache'
set-env: true
Expand Down
103 changes: 77 additions & 26 deletions content/doc/administrate/tcp-redirections.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
type: docs
title: TCP redirections with Clever Tools
title: TCP redirections
shortdesc: TCP redirections to port 4040 of your instance
tags:
- administrate
Expand All @@ -11,47 +11,98 @@
type: docs
---
{{< callout type="warning" >}}
TCP redirections are currently available free of charge as long as the feature is still considered in a BETA stage.
TCP redirections are currently available free of charge as long as the feature is in BETA stage.

Check notice on line 14 in content/doc/administrate/tcp-redirections.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/administrate/tcp-redirections.md#L14

[Google.Acronyms] Spell out 'BETA', if it's unfamiliar to the audience.
Raw output
{"message": "[Google.Acronyms] Spell out 'BETA', if it's unfamiliar to the audience.", "location": {"path": "content/doc/administrate/tcp-redirections.md", "range": {"start": {"line": 14, "column": 86}}}, "severity": "INFO"}
Once the feature leaves the BETA stage, it won't be free anymore.
{{< /callout >}}

## What is a TCP redirection?

A regular application on Clever Cloud needs to listen on port 8080 and answer to HTTP traffic.
Our reverse proxies then make your application available using HTTP(s) using your domain name.
Every application hosted Clever Cloud must listen on port 8080 and answer to HTTP traffic.
This is useful for both routing requests and monitoring purposes.

Some applications might additionally want to use a binary protocol, with raw TCP interactions.
For this scenario, your application will have to listen for TCP traffic on port 4040.
Once this is done, all you need to do is add a TCP redirection to your application. A port will be
provided to you, and your TCP listener will be available on your domain name using the provided port.
However, some applications might additionnally require binary protocol, with raw TCP interactions.

Check failure on line 23 in content/doc/administrate/tcp-redirections.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/administrate/tcp-redirections.md#L23

[Vale.Spelling] Did you really mean 'additionnally'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'additionnally'?", "location": {"path": "content/doc/administrate/tcp-redirections.md", "range": {"start": {"line": 23, "column": 34}}}, "severity": "ERROR"}
PLhuillery marked this conversation as resolved.
Show resolved Hide resolved
In that case, you can use a TCP redirection to route TCP traffic, through our reverse proxies, to your application.

Check warning on line 24 in content/doc/administrate/tcp-redirections.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/administrate/tcp-redirections.md#L24

[Google.We] Try to avoid using first-person plural like 'our'.
Raw output
{"message": "[Google.We] Try to avoid using first-person plural like 'our'.", "location": {"path": "content/doc/administrate/tcp-redirections.md", "range": {"start": {"line": 24, "column": 75}}}, "severity": "WARNING"}
PLhuillery marked this conversation as resolved.
Show resolved Hide resolved

Every application can be configured to receive TCP traffic on the port 4040.

Check notice on line 26 in content/doc/administrate/tcp-redirections.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/administrate/tcp-redirections.md#L26

[Google.Passive] In general, use active voice instead of passive voice ('be configured').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('be configured').", "location": {"path": "content/doc/administrate/tcp-redirections.md", "range": {"start": {"line": 26, "column": 23}}}, "severity": "INFO"}
We then assign a specific port to your application to expose it to TCP traffic. This port is chosen at random above 5000.

Check warning on line 27 in content/doc/administrate/tcp-redirections.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/administrate/tcp-redirections.md#L27

[Google.We] Try to avoid using first-person plural like 'We'.
Raw output
{"message": "[Google.We] Try to avoid using first-person plural like 'We'.", "location": {"path": "content/doc/administrate/tcp-redirections.md", "range": {"start": {"line": 27, "column": 1}}}, "severity": "WARNING"}

Check notice on line 27 in content/doc/administrate/tcp-redirections.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/administrate/tcp-redirections.md#L27

[Google.Passive] In general, use active voice instead of passive voice ('is chosen').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('is chosen').", "location": {"path": "content/doc/administrate/tcp-redirections.md", "range": {"start": {"line": 27, "column": 91}}}, "severity": "INFO"}

Check warning on line 27 in content/doc/administrate/tcp-redirections.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/administrate/tcp-redirections.md#L27

[Google.WordList] Use 'preceding' instead of 'above'.
Raw output
{"message": "[Google.WordList] Use 'preceding' instead of 'above'.", "location": {"path": "content/doc/administrate/tcp-redirections.md", "range": {"start": {"line": 27, "column": 111}}}, "severity": "WARNING"}
PLhuillery marked this conversation as resolved.
Show resolved Hide resolved

Use this specific port to send and receive TCP traffic.

{{< callout type="warning" >}}
The application must still be listening to the 8080 port, regardless of TCP configuration.
{{< /callout >}}

## What is a namespace?

When creating a TCP redirection, you will need to choose in which namespace you want to create it.
If you are a Premium customer with dedicated reverse proxies, you will have your own namespace.
If you are not a Premium customer and want to use a custom domain name, you will have to use the
"default" namespace.
If you want to use a cleverapps domain, you will have to use the "cleverapps" namespace.
Clever cloud manages a fleet of reverse proxies that fulfill different purposes, depending on their type and region.
A namespace is a group of reverse proxies. You may encounter:

Check failure on line 38 in content/doc/administrate/tcp-redirections.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/administrate/tcp-redirections.md#L38

[Vale.Spelling] Did you really mean 'namespace'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'namespace'?", "location": {"path": "content/doc/administrate/tcp-redirections.md", "range": {"start": {"line": 38, "column": 3}}}, "severity": "ERROR"}

- `default`: the stable public group of your region
- `cleverapps`: the group behind all the `cleverapps.io` domains
- dedicated name: if you are a premium customer with dedicated reverse proxies

`clever tcp-redirs list-namespaces` will provide you with a list of namespaces that you are allowed
to use for the current application.
Use `default` or dedicated namespace for applications with a custom domain name.

Check failure on line 44 in content/doc/administrate/tcp-redirections.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/administrate/tcp-redirections.md#L44

[Vale.Spelling] Did you really mean 'namespace'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'namespace'?", "location": {"path": "content/doc/administrate/tcp-redirections.md", "range": {"start": {"line": 44, "column": 28}}}, "severity": "ERROR"}
Use `cleverapps` for applications under the `cleverapps.io` domain.
If your application has both a custom domain name and a `cleverapps.io` one, you may activate TCP redirections on both of them.
Note that this generates two different ports, one for each domain.
You should use one or the other depending on the domain name you use in your request.

To list the possible redirections available to your application, you can use the following:

```bash
clever tcp-redirs list-namespaces
```

## Creating a new TCP redirection

Creating a new TCP redirection is as simple as `clever tcp-redirs add --namespace default` where
you can obviously replace "default" by the namespace of your choice. You will be prompted with
the port that has been assigned to you and you will be able to contact your application's TCP
listener using `tcp://your-domain-name:the-port/`
### With the console

From your console, select your application. In the secondary menu, go to **TCP redirections**.
From there, you can create a TCP redirection for a specific namespace (see [namespaces doc](#what-is-a-namespace?))

Check failure on line 61 in content/doc/administrate/tcp-redirections.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/administrate/tcp-redirections.md#L61

[Vale.Spelling] Did you really mean 'namespace'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'namespace'?", "location": {"path": "content/doc/administrate/tcp-redirections.md", "range": {"start": {"line": 61, "column": 61}}}, "severity": "ERROR"}

Check failure on line 61 in content/doc/administrate/tcp-redirections.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/administrate/tcp-redirections.md#L61

[Vale.Spelling] Did you really mean 'namespaces'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'namespaces'?", "location": {"path": "content/doc/administrate/tcp-redirections.md", "range": {"start": {"line": 61, "column": 77}}}, "severity": "ERROR"}

The creation is instantaneous. Find the TCP redirection port on this page.

![Redirection console](/images/doc/TCP_redirection_console.png)

### With the Clever CLI

You can use the following command to create a TCP redirection from the CLI:

```bash
clever tcp-redirs add --namespace default
```

Depending on your situation, you should replace `default` with the appropriate namespace.

Check failure on line 75 in content/doc/administrate/tcp-redirections.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/administrate/tcp-redirections.md#L75

[Vale.Spelling] Did you really mean 'namespace'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'namespace'?", "location": {"path": "content/doc/administrate/tcp-redirections.md", "range": {"start": {"line": 75, "column": 80}}}, "severity": "ERROR"}

The port assigned to your application displays right after the TCP redirection creation.
You can then contact your application over TCP using `tcp://your-domain-name:the-port/`.

## Managing redirections

### Listing active redirections

To visualize your application's redirections:

- from your console, an active redirection has a green tick next to it
- from the Clever CLI, you can use:

```bash
clever tcp-redirs
```

## Listing active TCP redirections
### Deleting redirections

You can list active TCP redirections for the current application using `clever tcp-redirs`
To delete a redirection on an application:

## Deleting a TCP redirection
- from your console, use the `delete` button next to the redirection
- from the Clever CLI, use:

First, you need to know which port was allocated to you, and in which namespace. You can list
the active TCP redirections to make sure you have the proper data.
```bash
clever tcp-redirs remove (port) --namespace (namespace)
```

We'll use namespace "default" and port "42" for this example.
Example: if your redirection is on port **5500** and the **default** namespace, the command would be

Check failure on line 104 in content/doc/administrate/tcp-redirections.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/doc/administrate/tcp-redirections.md#L104

[Vale.Spelling] Did you really mean 'namespace'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'namespace'?", "location": {"path": "content/doc/administrate/tcp-redirections.md", "range": {"start": {"line": 104, "column": 70}}}, "severity": "ERROR"}

You can now remove your TCP redirection using `clever tcp-redirs remove 42 --namespace default`.
```bash
clever tcp-redirs remove 5500 --namespace default
```
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/cnivolle/hextra //to update

go 1.21

require github.com/imfing/hextra v0.8.0 // indirect
require github.com/imfing/hextra v0.8.2 // indirect
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
github.com/imfing/hextra v0.8.0 h1:bG2GavmsMAgRRCrm+N4c+m6mBm9KYrgGH0mgaJpIXjM=
github.com/imfing/hextra v0.8.0/go.mod h1:cEfel3lU/bSx7lTE/+uuR4GJaphyOyiwNR3PTqFTXpI=
github.com/imfing/hextra v0.8.2 h1:/IykSIAywgKfhKUBgAW+dCCjrJWJNny4jr9qvdXfch0=
github.com/imfing/hextra v0.8.2/go.mod h1:cEfel3lU/bSx7lTE/+uuR4GJaphyOyiwNR3PTqFTXpI=
2 changes: 1 addition & 1 deletion layouts/partials/openapi/head_openapi.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


<!-- Google Analytics -->
{{- if and .Site.GoogleAnalytics (eq hugo.Environment "production") }}
{{- if and .Site.Config.Services.GoogleAnalytics.ID (eq hugo.Environment "production") }}
<link rel="preconnect" href="https://www.googletagmanager.com" crossorigin />
{{ partial "google-analytics.html" . }}
{{- end }}
Expand Down
65 changes: 0 additions & 65 deletions layouts/partials/shortcodes/card.html

This file was deleted.

Binary file added static/images/doc/TCP_redirection_console.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading