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
81 changes: 68 additions & 13 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,37 +11,93 @@
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.
Most of Clever Cloud's applications must listen on port 8080 and answer to HTTP traffic.
Keksoj marked this conversation as resolved.
Show resolved Hide resolved
This serves requests routing as well as monitoring purposes.

However, some applications might require binary protocol, with raw TCP interactions.
Keksoj marked this conversation as resolved.
Show resolved Hide resolved
In that case, you can use a TCP redirection to route TCP traffic from reverse proxies to your application.
Keksoj marked this conversation as resolved.
Show resolved Hide resolved

The IN port on reverse proxies (public side) is the usual 4040.
Keksoj marked this conversation as resolved.
Show resolved Hide resolved
The TCP redirection assigns a random OUT port specifically to your application (starting from port 5000)

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.Acronyms] Spell out 'OUT', if it's unfamiliar to the audience.
Raw output
{"message": "[Google.Acronyms] Spell out 'OUT', if it's unfamiliar to the audience.", "location": {"path": "content/doc/administrate/tcp-redirections.md", "range": {"start": {"line": 27, "column": 38}}}, "severity": "INFO"}
Configure the application to listen to this provided port.
Keksoj marked this conversation as resolved.
Show resolved Hide resolved

Once done, your application can now send and receive TCP traffic.


Our reverse proxies then make your application available using HTTP(s) using your domain name.
Wonshtrum marked this conversation as resolved.
Show resolved Hide resolved

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
juliamrch marked this conversation as resolved.
Show resolved Hide resolved
Keksoj marked this conversation as resolved.
Show resolved Hide resolved
Keksoj marked this conversation as resolved.
Show resolved Hide resolved
provided to you, and your TCP listener will be available on your domain name using the provided port.


## 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
A namespace is a group of reverse proxies: either the default public ones, cleverapps.io, or dedicated ones

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

View workflow job for this annotation

GitHub Actions / vale

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

[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": 42, "column": 3}}}, "severity": "ERROR"}
A TCP redirection is associated with one of those 3 groups.

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

View workflow job for this annotation

GitHub Actions / vale

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

[Google.Passive] In general, use active voice instead of passive voice ('is associated').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('is associated').", "location": {"path": "content/doc/administrate/tcp-redirections.md", "range": {"start": {"line": 43, "column": 19}}}, "severity": "INFO"}
Keksoj marked this conversation as resolved.
Show resolved Hide resolved

- If you are a regular customer and want to use a custom domain name, you have to use the
"default" namespace.
If you want to use a cleverapps domain, you will have to use the "cleverapps" namespace.
- If you are a premium customer with dedicated reverse proxies, you have your own namespace.

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

View workflow job for this annotation

GitHub Actions / vale

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

[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": 47, "column": 83}}}, "severity": "ERROR"}
- If you want to use a cleverapps.io domain, you can use the "cleverapps" namespace.

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

View workflow job for this annotation

GitHub Actions / vale

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

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

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

View workflow job for this annotation

GitHub Actions / vale

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

[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": 48, "column": 75}}}, "severity": "ERROR"}
Keksoj marked this conversation as resolved.
Show resolved Hide resolved

`clever tcp-redirs list-namespaces` will provide you with a list of namespaces that you are allowed
to use for the current application.
If you aren't sure what are the possible namespaces for your application, you can use `clever tcp-redirs list-namespaces`.

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

View workflow job for this annotation

GitHub Actions / vale

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

[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": 50, "column": 42}}}, "severity": "ERROR"}
Keksoj marked this conversation as resolved.
Show resolved Hide resolved
This command lists all the possible namespaces current application.

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

View workflow job for this annotation

GitHub Actions / vale

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

[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": 51, "column": 37}}}, "severity": "ERROR"}
Keksoj marked this conversation as resolved.
Show resolved Hide resolved

## Creating a new TCP redirection

Creating a new TCP redirection is as simple as `clever tcp-redirs add --namespace default` where
### With the console

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

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

View workflow job for this annotation

GitHub Actions / vale

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

[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": 58, "column": 79}}}, "severity": "ERROR"}

The creation is instantaneous. Find the application assigned port on this page.
Keksoj marked this conversation as resolved.
Show resolved Hide resolved

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

### With the Clever CLI

You can use the `clever tcp-redirs add --namespace default` command to create a TCP redirection from the CLI.
Depending on your situation, you should replace `default` with the appropriate namespace.

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

View workflow job for this annotation

GitHub Actions / vale

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

[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": 67, "column": 80}}}, "severity": "ERROR"}

The port assigned to your application is displayed right after the TCP redirection creation.

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

View workflow job for this annotation

GitHub Actions / vale

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

[Google.Passive] In general, use active voice instead of passive voice ('is displayed').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('is displayed').", "location": {"path": "content/doc/administrate/tcp-redirections.md", "range": {"start": {"line": 69, "column": 39}}}, "severity": "INFO"}
Keksoj marked this conversation as resolved.
Show resolved Hide resolved
You can then contact your application's TCP listener using `tcp://your-domain-name:the-port/`.

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
Wonshtrum marked this conversation as resolved.
Show resolved Hide resolved
listener 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
```

### Deleting redirections

To delete a redirection on an application:

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

```bash
clever tcp-redirs remove (port) --namespace (namespace)
```

Example: if your redirection is on port **5500** and the **default** namespace, the command would be
`clever tcp-redirs remove 5500 --namespace default`

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

View workflow job for this annotation

GitHub Actions / vale

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

[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": 100, "column": 34}}}, "severity": "ERROR"}

## Listing active TCP redirections

Expand All @@ -54,4 +110,3 @@

We'll use namespace "default" and port "42" for this example.
juliamrch marked this conversation as resolved.
Show resolved Hide resolved

You can now remove your TCP redirection using `clever tcp-redirs remove 42 --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