how to config rtmp://example.com when using SRS livestream

850 Views Asked by At

I use Nginx as proxy & SRS as Livestream server, here is my Nginx config for server block:

  `server {
    listen       80;
    listen       443 ssl http2;
    server_name  example.com;
    ssl_certificate      /usr/local/srs/conf/server.crt;
    ssl_certificate_key  /usr/local/srs/conf/server.key;

    # For SRS homepage, console and players
    #   http://r.ossrs.net/console/
    #   http://r.ossrs.net/players/
    location / {
       proxy_pass http://127.0.0.1:8080/;
    }
    # For SRS streaming, for example:
    #   http://r.ossrs.net/live/livestream.flv
    #   http://r.ossrs.net/live/livestream.m3u8
    location ~ /.+/.*\.(flv|m3u8|ts|aac|mp3)$ {
       proxy_pass http://127.0.0.1:8080$request_uri;
    }
    # For SRS backend API for console.
    location /api/ {
       proxy_pass http://127.0.0.1:1985/api/;
    }
    # For SRS WebRTC publish/play API.
    location /rtc/ {
       proxy_pass http://127.0.0.1:1985/rtc/;
    }
}`

For the config it work fine for VLC player to play the livestream from URL look like https://example.com/live/livestream.m3u8

But from my OBS software to publish the stream, I need use Ip instead the domain to work properly, look like: rtmp://my_public_ip/live

if I replace by the url look like rtmp://example.com/live => OBS doesn't work!

How can I publish stream from OBS via my domain?

I tried to use the vhost config but its didn't work.

1

There are 1 best solutions below

0
On

Please publish to SRS directly not NGINX, and use the config for OBS:

  • Server: rtmp://srs_server_ip/live
  • StreamKey: livestream

Note that never put the livestream in Server config, it should be in the StreamKey, which is confusing.

Please read more from here