RussellLuo / caddy-ext

Various Caddy v2 extensions (a.k.a. modules).
MIT License
96 stars 21 forks source link

Question about setting up #17

Open gymnae opened 1 year ago

gymnae commented 1 year ago

Hi there, I'd love to use the layer4 app without giving up on the Caddyfile, since it's YAMLness makes it easy for me to configure. Could your layer4 extension be used for the following scenario:

caddy server running as docker container, listening on 0.0.0.0443/tcp and 0.0.0.080/udp and 0.0.0.0:443/udp and 0.0.0.0:80/udp

  1. Proxy turn.domain.tld UDP & TCP traffic received and sent on port 443 in raw form to a docker container running on port 3389 (requires also tls)
  2. Proxy vpn.domain.tld wireguard UDP traffic received and sent on port 443 to a docker container listening on the typical wireguard port (no tls required) Proxy other UDP traffic received with further sub-domains to other containers

(all docker containers share the same docker network, so they can be reached via local IP or DNS)

And leave the http reverse proxies as they are already defined?

Could something like this work:

        https_port 443
        http_port 80
        servers tcp/:443 {
                }
        layer4 {
               udp/:443 {
       turn.domain.tld {
               tls
               proxy {
                       to udp/signaling_coturn:3389
               }
        }
       vpn.domain.tld {
               tls
               proxy {
                       to udp/wireguard:51820
               }
        }
        sub.domain1.tld, sub.domain2.tld, sub.domain3.tld, sub.domain4.tld {
               tls
               proxy {
                       to udp/dnsproxy:853
               }
        }
               }
        }
        # normal http servers
sub.domain.tld {
...

When trying with

        servers tcp/0.0.0.0:443 {
                protocols h1 h2
        }
        layer4 {
               udp/0.0.0.0:443 {

I get the following warning: "layer4 app module: start: listen udp 0.0.0.0:443: bind: address already in use"

gymnae commented 1 year ago

Created a topic in the caddy community forum related to my question: https://caddy.community/t/help-with-layer4-caddy2-ext-layer4-proxy-both-udp-and-tcp/19719

RussellLuo commented 1 year ago

Hi @Gymnae, is there anything this plugin can help you?