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
87 changes: 74 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,38 +11,99 @@
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 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": 83}}}, "severity": "INFO"}
PLhuillery marked this conversation as resolved.
Show resolved Hide resolved
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"}
The application must be configured to be listening to this provided port.

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

View workflow job for this annotation

GitHub Actions / vale

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

[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": 28, "column": 22}}}, "severity": "INFO"}
PLhuillery marked this conversation as resolved.
Show resolved Hide resolved

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


<!-- A regular application on Clever Cloud needs to listen on port 8080 and answer to HTTP traffic.
PLhuillery marked this conversation as resolved.
Show resolved Hide resolved
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.
provided to you, and your TCP listener will be available on your domain name using the provided port. -->
PLhuillery marked this conversation as resolved.
Show resolved Hide resolved


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

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

View workflow job for this annotation

GitHub Actions / vale

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

[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": 45, "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 49 in content/doc/administrate/tcp-redirections.md

View workflow job for this annotation

GitHub Actions / vale

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

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

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

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 'namespace'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'namespace'?", "location": {"path": "content/doc/administrate/tcp-redirections.md", "range": {"start": {"line": 50, "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 52 in content/doc/administrate/tcp-redirections.md

View workflow job for this annotation

GitHub Actions / vale

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

[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": 52, "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 53 in content/doc/administrate/tcp-redirections.md

View workflow job for this annotation

GitHub Actions / vale

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

[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": 53, "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`.
PLhuillery marked this conversation as resolved.
Show resolved Hide resolved
From there, you can create a `default` or `cleverapps` TCP redirection (see above for namespaces)

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

View workflow job for this annotation

GitHub Actions / vale

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

[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": 60, "column": 77}}}, "severity": "WARNING"}

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

View workflow job for this annotation

GitHub Actions / vale

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

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

The creation is instantaneous. The assigned port to the application can be seen on this page.

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

View workflow job for this annotation

GitHub Actions / vale

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

[Google.Passive] In general, use active voice instead of passive voice ('be seen').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('be seen').", "location": {"path": "content/doc/administrate/tcp-redirections.md", "range": {"start": {"line": 62, "column": 73}}}, "severity": "INFO"}
PLhuillery 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 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

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

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

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

View workflow job for this annotation

GitHub Actions / vale

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

[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": 71, "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/`.

<!--Creating a new TCP redirection is as simple as `clever tcp-redirs add --namespace default` where
PLhuillery marked this conversation as resolved.
Show resolved Hide resolved
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/`
listener using `tcp://your-domain-name:the-port/` -->
PLhuillery marked this conversation as resolved.
Show resolved Hide resolved

## 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)`
PLhuillery marked this conversation as resolved.
Show resolved Hide resolved
```

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

<!--
PLhuillery marked this conversation as resolved.
Show resolved Hide resolved
## Listing active TCP redirections

You can list active TCP redirections for the current application using `clever tcp-redirs`
Expand All @@ -54,4 +115,4 @@

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`.
You can now remove your TCP redirection using `clever tcp-redirs remove 42 --namespace default`. -->
PLhuillery marked this conversation as resolved.
Show resolved Hide resolved
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