Thursday, April 3, 2014

Proxy Protocol support in nginx-rtmp-module 1.1.4

The new version of nginx-rtmp-module has proxy protocol support added. Proxy protocol lets you put nginx behind a TCP-proxy and still have real client address. Here's an example of nginx.conf setting a listener with proxy protocol enabled.
rtmp {
    server {
        listen 1935; # usual listener
        listen 1936 proxy_protocol; # handles proxy protocol
        
        application myapp {
            live on;
        }
    }
}
If proxy_protocol option is specified in listen directive, such listener expects proxy protocol header from its client before RTMP data and will not handle plain RTMP requests. The client address received via proxy protocol is used everywhere instead of the proxy address including logs and on_XXX callbacks.

Notable software having client-side proxy protocol support allowing you to proxy RTMP requests to nginx-rtmp-module:

9 comments:

  1. Dear Mr Arutyunyan,

    When I use your nginx configuration for video on demand (vod) correctly, I cannot seem to open mp4 files (haven't tested flv) when they are not in the app specified file path.

    For example

    rtmp {
    server {
    listen 1935;
    chunk_size 4000;
    application vod {
    play /videos/mp4s ;
    }
    }
    }

    Lets me open the identical files /videos/mp4s/sample1.mp4 but not /videos/mp4s/subdirectory/sample1.mp4

    Also when I successfully open a mp4 rtmp stream using VLC player via the url: rtmp://mydomain.com:1935/vod/sample1.mp4 it plays, but it does not let me seek. When I open the same file via http:// protocol, it plays and seeks fine.

    It would be very very pleasant if you could enlighten me with a solution.

    ReplyDelete
  2. This essay is very attractive and useful. Your this work defiantly helps other.
    New Album Releases UK proxy

    ReplyDelete
  3. Hi, Roman,
    I really like to keep up with this blog. But after google reader shutdown, there are no good rss reader to use. Could you please open the option "share after posting" on the Google+ tab of blogger setting page. So people followed you on G+ get notified when you publish a new post.

    ReplyDelete
  4. I think you made awesome decision the moment when you choose this topic of the blog article here. Very usefull informatiom.
    Mp3Juices UK proxy
    .

    ReplyDelete
  5. Is it possible to use HDFVR recorder with nginx-rtmp?

    ReplyDelete
  6. Your nice work is very attractive and impressive.
    access Files tube in UK

    ReplyDelete
  7. I have configured nginx-rtmp and able to stream the video. Now I am setting HAProxy to point to nginx-rtmp server but could not make it work. I have included the

    "listen 1936 proxy_protocol" in my nginx.conf



    I followed this configuration taken from
    http://blog.haproxy.com/2012/09/21/high-available-rtmp-platform-with-haproxy-and-crtmpserver/
    ###################
    frontend ft_rtpm
    bind 10.1.31.1 name rtmp
    mode tcp
    maxconn 600
    default_backend bk_rtmp

    backend bk_rtmp
    mode tcp
    balance roundrobin
    stick store-request src
    stick-table type ip size 200k expire 20m
    stick on src
    source 0.0.0.0 usesrc clientip
    server media01 10.0.0.1:1936 check maxconn 200 weight 10
    server media02 10.0.0.2:1936 check maxconn 200 weight 10
    ###################


    Am I missing something?

    ReplyDelete
  8. I have configured nginx-rtmp and able to stream the video. Now I am setting HAProxy to point to nginx-rtmp server but could not make it work. I have included the

    "listen 1936 proxy_protocol" in my nginx.conf



    I followed this configuration taken from
    http://blog.haproxy.com/2012/09/21/high-available-rtmp-platform-with-haproxy-and-crtmpserver/
    ###################
    frontend ft_rtpm
    bind 10.1.31.1 name rtmp
    mode tcp
    maxconn 600
    default_backend bk_rtmp

    backend bk_rtmp
    mode tcp
    balance roundrobin
    stick store-request src
    stick-table type ip size 200k expire 20m
    stick on src
    source 0.0.0.0 usesrc clientip
    server media01 10.0.0.1:1936 check maxconn 200 weight 10
    server media02 10.0.0.2:1936 check maxconn 200 weight 10
    ###################


    Am I missing something?

    ReplyDelete