RTSP proxying with Caddy

System info:

OS: Linux Ubuntu 22.04
Kernel: 5.15.0-69-generic
Caddy version: 2b3046de36bad70bd7e48478c99a8a030fb35b98 (27 Mar 23 22:40 UTC)

Problem

I’m using MediaMTX to proxy an RTSP stream via a WebRTC endpoint. The MediaMTX server exposes a WebRTC endpoint on port 8889.

I need to run the MediaMTX server on a VPS which is using Caddy as a reverse proxy and a static server to serve some other files. I want to reverse proxy a certain path to port 8889 but I get application/x-unknown-filetype errors in the frontend.

Current setup

  • Caddyfile

    http://instisafe.iitm.ac.in {
    	handle_path /relay/* {
    		@denied not remote_ip forwarded private_ranges
    		abort @denied	
    		reverse_proxy :8889
    	}
    }
    
  • Usage in frontend

    <iframe src="https://instisafe.iitm.ac.in/relay/$cameraID"></iframe>
    

Potential causes/solutions

  • After a little digging, I found out that this might be happening because Caddy doesn’t support raw TCP traffic. caddy-l4 might be of help.
  • Right now, I’m using MediaMTX to convert RTSP :arrow_right: WebRTC and expose it to the frontend. I might try with other methods like HLS.

Correct. Vanilla Caddy only does HTTP. If you need TCP proxying, then you need to use caddy-l4 instead.

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