srs icon indicating copy to clipboard operation
srs copied to clipboard

HTTP Redirect Support in HTTP Callback?

Open SoraBytes opened this issue 4 years ago • 4 comments
trafficstars

This is a feature request for the HTTP 301/302 Redirect that NGINX RTMP Module supports for on_publish. Basically I am requesting to have the on_publish follow a 301/302 redirect to a new stream name.

Stream to rtmp://[vhost]/[app]/livestream Then PHP on_publish script returns "301/302" with a location So it becomes rtmp://[vhost]/[app]/[location]

SoraBytes avatar Mar 08 '21 07:03 SoraBytes

Could you please describe the use scenario?

winlinvip avatar May 20 '21 00:05 winlinvip

The use case: Ability to authorize individuals stream keys that can change, while keeping a display name. I've already published a script that works with RTMP/FLV module for nginx from winshining, but I would like to use SRS. This functionality is missing, That works in the other RTMP modules as far as I can tell.

Basically as follows:

  1. User with "StreamKey"
  2. OBS Stream Server -> rtmp://[vhost]/[app]
  3. OBS Stream Key -> StreamKey
  4. Stream Becomes -> rtmp://[vhost]/[app]/StreamKey
  5. on_publish -> rtmp://[vhost]/[app]/StreamKey -> 301/302 -> rtmp://[vhost]/[app]/UserName

Reference to NGINX RTMP "on_play" and all the other directives such as "on_publish" support this.

If 200 -> Stream at rtmp://[vhost]/[app]/StreamKey if 301/302 -> rtmp://[vhost]/[app]/StreamKey -> rtmp://[vhost]/[app]/UserName If 403 -> Stream is denied, and will not go live.

SoraBytes avatar May 20 '21 23:05 SoraBytes

Not a use scenario, it's a requirement description.

winlinvip avatar Jun 17 '21 00:06 winlinvip

Besides just changing a local name, nginx-rtmp also allows you to dynamically push/forward the stream to remote servers on play with 3xx directive:

302 rtmp://1.2.3.4:1935/live/newstream will automatically "push" the stream to the new remote IP.

HTTP 3xx redirects RTMP to another stream whose name is taken from Location HTTP response header. If new stream name is started with rtmp:// then remote relay is created instead. Relays require that IP address is specified instead of domain name

gittyup2018 avatar Mar 27 '22 23:03 gittyup2018