Author |
|
rayj2018
Joined: 05 Jun 2018 Posts: 2 Location: USA, Port Richey, Fl.
|
Posted: Wed 06 Jun '18 0:38 Post subject: mod_rewrite question |
|
|
Can a mod_rewrite rule take an incoming rtmp and forward it to a co-located container?
I have an Ubuntu 16.04 host server with 4 LXD containers.
The containers are duplicate media servers.
So how this would work is like this:
A user initiates an RTMP stream from a video broadcasting app. The rtmp stream comes into the host and it is then routed to one of the containers, based on the URL. For instance rtmp://"IP":1935/lpc1 would eventually route to container 1 at the IP. Of course the container is a different IP than the host.
Can this be done?
Thanks,
Ray |
|
Back to top |
|
admin Site Admin
Joined: 15 Oct 2005 Posts: 692
|
Posted: Wed 06 Jun '18 10:36 Post subject: |
|
|
Please use a meaningful, specific subject. See Forum Rules |
|
Back to top |
|
ray2018
Joined: 04 Mar 2018 Posts: 6 Location: USA
|
Posted: Wed 06 Jun '18 14:29 Post subject: Using mod_rewrite to forward to another URL? |
|
|
admin wrote: | Please use a meaningful, specific subject. See Forum Rules |
I don't know how to change the original subject line? |
|
Back to top |
|
mraddi
Joined: 27 Jun 2016 Posts: 152 Location: Schömberg, Baden-Württemberg, Germany
|
Posted: Wed 06 Jun '18 21:09 Post subject: |
|
|
Hello Ray,
I'm not sure if apache is able to handle RTMP-streams.
For this I have used NginX (free - compiled with RTMP-module) or Wowza (which is not free ).
Best regards
Matthias |
|
Back to top |
|
ray2018
Joined: 04 Mar 2018 Posts: 6 Location: USA
|
Posted: Thu 07 Jun '18 14:40 Post subject: |
|
|
So if I use nginx w/rtmp module, can I then re-direct an incoming rtmp stream to another server?
Thanks,
Ray |
|
Back to top |
|
mraddi
Joined: 27 Jun 2016 Posts: 152 Location: Schömberg, Baden-Württemberg, Germany
|
Posted: Thu 07 Jun '18 16:04 Post subject: |
|
|
Hello Ray,
I've compiled NginX with RTMP-module and used the following configuration:
Code: | rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
}
application vod {
play /var/www/html/media/vod;
}
application live_rpt {
live on;
pull rtmp://192.168.0.4/live name=livestream live=1;
sync 300ms;
}
application vod_rpt {
play_local_path /var/www/html/media/vod_rpt_cache;
play /var/www/html/media/vod_rpt_cache http://192.168.0.4/media/vod;
sync 300ms;
}
}
} |
With this I can use the NginX to be used
* as Livestream-server (/live),
* as RTMP-repeater/RTMP-reverse-proxy (/live_rpt) for another server (192.168.0.4)
* as VideoOnDemand-server (/vod) playing mp4-files from local directory
* as VideoOnDemand-RTMP-repeater/-reverse-proxy (vod_rpt) for another server (192.168.0.4) with caching the files locally
Maybe with this config-snippet you get an idea how to to configure NginX to send "/lpc1" to backend-server A, "/lpc2" to backend-server B, ... |
|
Back to top |
|
ray2018
Joined: 04 Mar 2018 Posts: 6 Location: USA
|
Posted: Thu 07 Jun '18 21:52 Post subject: |
|
|
Thanks for taking the time to respond. I appreciate it.
So, how would the stream settings in OBS for instance be set to tell nginx/rtmp to pass the rtmp on to another server? And how would the nginx config look to accomplish this?
Thanks again,
Ray |
|
Back to top |
|
mraddi
Joined: 27 Jun 2016 Posts: 152 Location: Schömberg, Baden-Württemberg, Germany
|
Posted: Wed 13 Jun '18 22:52 Post subject: |
|
|
Hello Ray,
I've never used OBS up to now so I can't tell if/how you need to configure this software.
But from my point of view you don't have to configure anything special on the backend-(OBS-)systems that are behind a reverse-proxy (the same as you don't need special configuration on webservers that are behind a reverse-proxy-server).
Just to verify that I got your problem correctly:
* you have one big master-server connected to the network
* you have four (containered) RTMP-servers (live or VideoOnDemand?) in the backend that should be available via the one hostname/ip-address of the master-server
But why use four RTMP-servers instead of one? As it is containered the same phyiscal server has to bear all the load so distributing the load between different servers couldn't be the reason.
NginX (and Wowza - the two RTMP-servers I've used up to now) are able to handle more than one stream at the same time - either with different stream-names (/live/stream1, /live/stream2, ...) or within different paths (/live1/stream, /live2/stream, ...).
But I guess there are reasons you created your environment the way you did .
You can either
a) combine the four instances ob OBS into one (if possible) available directly on the master-server
b) or run NginX on the master-server and configure it according to the example already provided to run as a RTMP-repeater.
For b) I would suggest the following steps:
* ensure that NginX is already compiled with the RTMP-module or compile NginX yourself with this module
* configure it to server a RTMP-stream directly from an mp4-file on the harddrive - see the "vod"-part in the config-snippet I've posted some days ago - just as a test to ensure that NginX itself is running as expected able to server RTMP-stream-data
* afterwards you can add the configuration for every backend-OBS-server, which might look similar to this (just a guess because I don't know if you are serving live-RTMP-data and of course I don't know the stream-names/paths you are using on the backend-servers):
Code: | [...]
application lpc1 {
live on;
pull rtmp://192.168.1.11/live name=livestream live=1;
sync 300ms;
}
application lpc2 {
live on;
pull rtmp://192.168.1.12/live name=livestream live=1;
sync 300ms;
}
application lpc3 {
live on;
pull rtmp://192.168.1.13/live name=livestream live=1;
sync 300ms;
}
application lpc4 {
live on;
pull rtmp://192.168.1.14/live name=livestream live=1;
sync 300ms;
}
[...] |
Maybe this helps? |
|
Back to top |
|
ray2018
Joined: 04 Mar 2018 Posts: 6 Location: USA
|
Posted: Thu 21 Jun '18 16:24 Post subject: |
|
|
Thanks for the response mraddi.
So would the config you posted work for live video?
I thought the "pull" was for mp4 videos?
Thanks
Ray |
|
Back to top |
|
ray2018
Joined: 04 Mar 2018 Posts: 6 Location: USA
|
Posted: Thu 21 Jun '18 17:54 Post subject: |
|
|
I am using 4 containers that will be used by 4 separate live video streamers. So one broadcaster would essentially be the "owner" of one container. Another broadcaster would "own" another container, and so on.
Ray |
|
Back to top |
|