deepch / RTSPtoWeb

RTSP Stream to WebBrowser
MIT License
1.17k stars 284 forks source link

https error #402

Open juliananoro opened 7 months ago

juliananoro commented 7 months ago

Hello, I'm trying use the app through https with a openssl self-certification. I have generated a new server.crt and server.key file but I keep getting SSL errors.

the url on my react component: https://IP:443/stream/test1/channel/0/hls/live/index.m3u8

on browser I get: GET https://IP:443/stream/test1/channel/0/hls/live/index.m3u8 net::ERR_SSL_PROTOCOL_ERROR

and on terminal I get: 2023/11/06 14:15:45 http: TLS handshake error from IP:56409: acme/autocert: missing server name

this is my current config file: { "server": { "debug": true, "http_debug": false, "http_demo": true, "http_dir": "web", "http_login": "demo", "http_password": "demo", "http_port": ":8083", "https": true, "https_auto_tls": true, "https_auto_tls_name": "", "https_cert": "server.crt", "https_key": "server.key", "https_port": ":443", "ice_servers": ["stun:stun.l.google.com:19302"], "log_level": "debug", "rtsp_port": ":5541", "token": { "backend": "http://127.0.0.1/test.php" }, "defaults": { "audio": true } }, "streams": { "test1": { "channels": { "0": { "url": rtsp address, "debug": false, "audio": true }, "1": { "url": rtsp address, "debug": false, "audio": true } }, "name": "test1" } } }

note: I have also tried "https_auto_tls_name": "nametest" and updating acme.

XFreitas commented 7 months ago

Hi, I've tried this using Let's Encrypt and Docker volume to make it work fine. First, edit your config.json like this:

{
  "channel_defaults": {
    "on_demand": true
  },
  "server": {
    "debug": false,
    "http_debug": false,
    "http_demo": false,
    "http_dir": "",
    "http_login": "",
    "http_password": "",
    "http_port": ":8083",
    "https": true,
    "https_auto_tls": false,
    "https_auto_tls_name": "",
    "https_cert": "/config/server.crt",
    "https_key": "/config/server.key",
    "https_port": ":8084",
    "ice_credential": "",
    "ice_servers": [],
    "ice_username": "",
    "log_level": "info",
    "rtsp_port": "",
    "token": {
      "backend": "",
      "enable": false
    },
    "webrtc_port_max": 0,
    "webrtc_port_min": 0
  },
  "streams": {
    // your rtsp urls here
  }
}

Then, when you run Docker, execute it like this:

docker run --name rtsp-to-web /
     -v /path/to/config.json:/config/config.json /
     -v /etc/letsencrypt/live/your_url/fullchain.pem:/config/server.crt /
     -v /etc/letsencrypt/live/your_url/privkey.pem:/config/server.key /
     --network host /
     ghcr.io/deepch/rtsptoweb:latest

Remember to update the path to the certificates. I hope it works for you.

juliananoro commented 7 months ago

I don't have a domain for the rtspToWeb app, does it only work if i get a domain? Can't I use a self-certified certificate?

XFreitas commented 7 months ago

Yes, it will work with a self-signed certificate. Try following this tutorial from Let's Encrypt to create a self-signed certificate. I hope it will work.