TCP redirections
A TCP redirection opens a public port on the Clever Cloud load balancers and forwards its raw TCP traffic to port 4040 of your application. Use it for protocols other than HTTP, such as SFTP, MQTT, or a game server. TCP redirections are free.
How it works
- Your application listens on port
4040. A Docker container can use another port throughCC_DOCKER_EXPOSED_TCP_PORT - Clever Cloud chooses the public port. It stays the same while the redirection exists, even when the application redeploys
- Deployments still wait for the HTTP health check of your application on port
8080: a TCP redirection doesn’t replace it - The load balancers forward the bytes unchanged: your application handles TLS itself, with its own certificate
- Your application sees the address of the load balancer, not the one of the client
- With several instances, the load balancers spread new connections across them
Choose a namespace
A namespace is a group of load balancers. Each application can have one TCP redirection per namespace:
default: the load balancers of your custom domainscleverapps: the load balancers of thecleverapps.iodomains- A private namespace, for organisations with dedicated load balancers
Use the namespace of the domain your clients connect to. List the namespaces available with Clever Tools:
clever tcp-redirs list-namespacesCreate a TCP redirection
In the Console, open the TCP redirections page of your application, then click Create next to the namespace.
With Clever Tools, set the namespace with --namespace:
clever tcp-redirs add --namespace cleverappsThe command displays the public port, such as Successfully added tcp redirection on port: 24950. Clients then connect to this port on a domain of your application, here its cleverapps.io domain:
nc my-app.cleverapps.io 24950Replace the domain and the port with those of your application.
With Terraform, set namespace in the redirection attribute of the application: its read-only port holds the public port.
List and remove TCP redirections
The TCP redirections page of the Console shows each redirection and its port. With Clever Tools, list them in human or JSON format:
clever tcp-redirs
clever tcp-redirs --format jsonTo remove a redirection, click Delete next to it in the Console. With Clever Tools, set its port and its namespace:
clever tcp-redirs remove 24950 --namespace cleverappsRemoving the redirection stops new connections through its port. A new redirection in this namespace can get a different port.
Examples
- Mosquitto: an MQTT broker built on the Linux runtime
- Node.js TCP chat: a chat room to join with
nc - SFTPGo: an SFTP server exposed through a TCP redirection, with a web interface