1. The problem I’m having:
Thank you guys so much for Caddy! A real gem!
I am trying to configure Caddy as a reverse raw tcp proxy and use it with a match.host
.
My idea is to redirect an SSH request to a specific port on the localhost depending on the hostname.
I got a similar functionality but only for HTTPS requests.
Using the APIs I generate a new route at runtime where I create a randomdomain that I use for the match.host
to select the reverse proxy, e.g.:
"routes": [
{
"match": [
{
"host": [
"randomdomain.example.com"
]
}
],
"handle": [
{
"handler": "reverse_proxy",
"upstreams": [
{
"dial": ":5000"
}
]
}
]
}
]
It works without any problems.
I would like to achieve the same result using caddy-l4, in a scenario like this:
- "if the connection is TCP and the
host
is randomdomain.example.com then proxy the TCP to “localhost:1234”
But I can’t figure out how to find an alternative to match.host
in layer4
.
I understood that layer4 does not support match.host
, can you advise me how I could achieve the same result as the HTTPS case but with TCP (or better SSH) requests?
Thank you very much for the help.
3. Caddy version:
v2.7.5 h1:HoysvZkLcN2xJExEepaFHK92Qgs7xAiCFydN5x5Hs6Q=
4. How I installed and ran Caddy:
a. System environment:
- Ubuntu
- ec2 instance.
b. Command:
./caddy run --config caddy_config.json
d. My complete Caddy config:
{
"apps": {
"http": {
"servers": {
"example": {
"listen": [
":443"
],
"routes": []
}
}
}
}
}