Caddyfile + L4 plugin

Can the layer4 plug-in be paired with the Caddyfile with an import block?

The Caddyfile would be the main config, and the import directive would import the layer 4 json file.

1 Like

Howdy @victor!

The caddy-l4 module doesnā€™t support the Caddyfile, which is a bit of a bummer.

There is another extension that allows limited configuration of caddy-l4 via Caddyfile global options: caddy-ext/layer4 at master Ā· RussellLuo/caddy-ext Ā· GitHub

Beyond that, a large amount of special handling in the core Caddyfile adapter makes including Layer 4 support prohibitively difficult. If an effort could be made to port caddy-l4 into the official repository, this would be simpler, but that is an undertaking that requires skilled Caddy developers and contributors with the time and ability to prioritise that over other work, and I donā€™t believe there are any concrete plans for it in the works right now.

Your best bet, currently, is to write your Caddyfile as normal and then caddy adapt it to JSON to merge with your caddy-l4 configuration before deploying it.

1 Like

Thanks. Iā€™ll give this a try. Iā€™m basically looking to proxy UDP traffic to a webrtc server.

This works beautifully!

But I notice that caddy is only listening on TCP. Does it auto listen on UDP or what?

I opted for the plugin. Works excellent as of right now. My webrtc stream is working fine with SSL and everything.

1 Like

Still wondering about thisā€¦

Without extra plugins, Caddy serves HTTP, and HTTP is over TCP, except HTTP/3 which is over UDP (but uses TCP to inform clients that UDP is available).

If youā€™re using the L4 plugin then you need to specify whether you want to listen on TCP or UDP since it operates at a lower layer.

Understood.

I tried both TCP (default it seems) and UDP. For some reason the UDP listener closes within a few seconds. TCP works great.

Not finding anything in the logs either.

As soon as a connection is make via UDP, it stops listening.

The UDP proxy is currently a bit broken. I wonder if this patch fixes it for you!

Does the plug-in mentioned above build with this patch?

Oh, Iā€™m not sure about that. Probably though? No external config changes AFAIK.

Ok so it does automatically build with the l4-plugin, but how would I specify to include that pull request.

Build with --with github.com/mholt/caddy-l4=github.com/jtackaberry/caddy-l4@udp-server-overhaul

Basically = replaces the package with the fork, and @ specifies which branch to use on the fork.

Built successfully. UDP listener now stays on, but something must still be amiss because itā€™s not proxying the traffic. When I port forward directly to the server that is serving the UDP traffic, it works. But once I go through caddy-l4, it doesnā€™t.

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