Search code examples
nginxopenshiftrtmp

Openshift + NGINX RTMP


I've been trying to stream flv content from my openshift cartridge using nginx + rtmp module.

On my local machine, with the attached configuration, everything works just fine (I use ffplay for testing, e.g. ffplay rtmp://localhost:8080/test/streamkey)

When I try with the same configuration on openshift, I get the following error:

HandShake: Type mismatch: client sent 3, server answered 60 f=0/0   
RTMP_Connect1, handshake failed.

However, if I enable port-forwarding and test the stream server using ffplay rtmp://127.0.0.1:8080/test/streamkey, everything works fine. here are my port forwardings:

rhc port-forward myappname 
Checking available ports ... done
Forwarding ports ...

To connect to a service running on OpenShift, use the Local address

Service Local               OpenShift
------- -------------- ---- -----------------
nginx   127.0.0.1:8080  =>  127.10.103.1:8080

My cartridge is a "diy-0.1" cartridge. nginx 1.7.6 (also tested 1.4.4) + rtmp-module.

I suspect there are some issues with some proxy (apache?) that uses openshift for handling gears, maybe it does not allow rtmp headers(?)?

NB: Configuring nginx http-only works fine.

Can anybody help? I'm stuck, I think this is the first time I ask something on stackoverflow :-)

The nginx configuration (NB: the "play" path and the IP:PORT are taken using the openshift environment variables.):

rtmp {
     server {
         listen  127.10.103.1:8080;

         chunk_size 8192;

         application test {
                  play /var/lib/openshift/54da37644382ece45c000139/app-root/runtime/repo/public;
         }
     }
 }

Solution

  • There is an apache proxy in front of your application on OpenShift Online, and it is possible that the content is trying to be streamed as HTTP traffic instead of RTMP traffic, that is why you are getting the content mismatch, but if you do it through the port-forward, you are gaining direct access to your application and bypassing the proxy. That is why it works fine with the port forward. There is currently no way to bypass the apache reverse proxy through the public ip, please see this developer portal article for more information about how requests are routed to your application: https://developers.openshift.com/en/managing-port-binding-routing.html