mholt / caddy-l4

Layer 4 (TCP/UDP) app for Caddy
Apache License 2.0
968 stars 74 forks source link

Can you use the same ports as http app? #77

Open ledlamp opened 2 years ago

ledlamp commented 2 years ago

Or does this "app" work completely separate to the "http" app?

mholt commented 2 years ago

It needs to use a different port, otherwise there's contention: who accepts connections, the HTTP server or the TCP server? I guess both could technically share the listener, but then it'd be random and you'd have undefined behavior.

So you'd probably want to use this app and then proxy to the HTTP app depending on the routes you define.

There's a pull request open in Caddy to make it possible to pipe a connection from one module to another, without needing to do any proxying. That will be cool I think!

What is your use case? Telling me specific details about what you're trying to do will help me design and implement a more useful feature.

ledlamp commented 2 years ago

I was interested in running a TLS-passthrough proxy for i.e. Signal etc. But it has to run on 443 and I already have caddy there with lots of layer 7 proxies and file servers. I was hoping it could have been a simple addition without affecting the l7, but they have to be integrated for that.

If this caddy app works separately then I might as well use a completely separate program like haproxy in front. I guess this module could be used so http app can get client ip address from haproxy. But haproxy supports l7 so I might as well do all my basic l7 proxying directly from that as well.

So yeah, it sounds like that PR will be important to bring caddy up to par with haproxy and nginx etc, which can handle both l7 and l4 together. Otherwise, I don't see much value in this module 🤷‍♂️

WeidiDeng commented 2 years ago

@asdfisdffdg Can you try this branch, which added the ability to configure l4 as a caddy listener wrapper.

You have to write json config and http app must disable https though. If you want any help with configuration, @me and I'm glad to help you.