Issues ReverseProxying different domains using Net-Plugin

Hey there!
First things first:
I’m running Caddy v1.0.4 with the following arguments:
caddy "-agree=true" "-conf=/opt/caddy/caddy.conf" "-type=net" "-email=my@email.here"

So, I’m trying to proxy tcp traffic to different servers depending on which domain has been used. Basically a simple tcp reverse proxy.
When not specifying a domain, this works great - but only for a single server:

proxy :25565 192.168.14.10:25565 {
  host test1.domain.com
  tls off
}

This also, despite having “host” configured as a single domain, proxy’s all traffic hitting the WAN-IP on port 25565.

Now, when trying to proxy different domains to different servers like this (already with only one entry!):

proxy test1.domain.com:25565 192.168.14.10:25565 {
  host test1.domain.com
  tls off
}

I’m getting the following error:
Listen: listen tcp [WAN-IP-HERE]:25565: bind: cannot assign requested address

Since the host-directive doesn’t seem to do anything, stuff like

proxy :25565 192.168.14.10:25565 {
  host test1.domain.com
  tls off
}

proxy :25565 192.168.14.11:25565 {
  host test2.domain.com
  tls off
}

also doesn’t work:
Listen: listen tcp :25565: bind: address already in use

Have I just done something wrong or is there an issue with the proxy?

I might be wrong here so I hope @matt can correct me if so…

I think the problem is that since you’re proxying TCP, there’s no SNI available so there’s no way to know which domain name is used. I may be wrong but I think what you’re trying to do is impossible :man_shrugging:

Also I don’t think your syntax is correct, but I’m unsure because you may also just not have given us your entire config. I think you mean to do:

test1.domain.com:25565 {
  proxy / 192.168.14.10:25565 {
    host test1.domain.com
    tls off
  }
}

See https://caddyserver.com/v1/docs/caddyfile, you need a site label.

1 Like

He’s using the net server type, which has its own Caddyfile structure.

Unfortunately I don’t know enough about the net plugin to help here.

2 Likes

Ah - then @Tenou I think you’ll get better support if you ask on GitHub - pieterlouw/caddy-net: Proxy server type for Caddy server (https://github.com/mholt/caddy) but note that it looks unmaintained at this point. Sorry! Not true, there was a commit 3 days ago :open_mouth:

2 Likes

No worries, you tried :smiley:
Thanks for your input, I appreciate that.

1 Like

Yep, that was the info “Hey, I fixed it after months of it being broken”. That’s the reason I’m trying it out right now ^^

1 Like

Yeah, actually, I just got a ping a few days ago that there is interest in a v2 port.

Depending on the design discussions and how involved I can be, I might even consider bringing that into the fold of official plugins (in the caddyserver org).

1 Like

That’d be pretty neat. I’ve been using Caddy as a reverse proxy for all my webpages since the first day and now wanted to expand it for use with my gameservers aswell. HAProxy, for example, doesn’t support UDP and I’m already using Caddy so it’d be pretty great having that kind of functionality.
Well, for now I just hope that the author of the plugin responds to my issue :smiley:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.