V2 websocket stdin / stdout

1. Caddy version (caddy version): v2.4.6 h1:HGkGICFGvyrodcqOOclHKfvJC0qTU7vny/7FhYp9hNw=

2. How I run Caddy:

starts automatically as a service as installed with apt on ubuntu

a. System environment:

Ubuntu 20

b. Command:

wscat -c wss://moreassholes.com/echo

c. Service/unit/compose file:

N/A

d. My complete Caddyfile or JSON config:

moreassholes.com:443 {
        root * /mnt/nyfc/static
        templates
        file_server
        websocket /echo cat

3. The problem I’m having:

Can’t determine if version 2> supports running local programs with STDIN/STDOUT like V1 did and if so, how.

4. Error messages and/or full log output:

404 error when trying to use :
websocket /echo cat

5. What I already tried:

https://caddy.its-em.ma/v1/docs/websocket

6. Links to relevant resources:

https://caddy.its-em.ma/v1/docs/websocket

No, that functionality doesn’t exist in Caddy v2.

It would be relatively trivial to write a plugin that does this though.

See the caddy-exec plugin which is equipped to run arbitrary commands over HTTP. It doesn’t output the results back to the client though. But you could use it as a basis for your own plugin.

You can also refer to the Caddy v1 codebase to see how it was done there (note: Caddy’s internals are very different in v2 compared to v1, but the request handler logic should still be similar)

Thank you! I’m going to use websocketd. I just had seen the prior support built in and hoped that would be a better solution.

1 Like

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