Advertisement
ustoopia

Instructions setting up Nginx+RTMP

Nov 9th, 2018
7,060
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 3.29 KB | None | 0 0
  1. FIRST INSTALL THESE USEFUL / REQUIRED PACKAGES
  2.  
  3.     sudo apt-get install wget unzip software-properties-common dpkg-dev git make gcc automake build-essential zlib1g-dev libpcre3 libpcre3-dev libssl-dev libxslt1-dev libxml2-dev libgd-dev libgeoip-dev libgoogle-perftools-dev libperl-dev pkg-config autotools-dev gpac ffmpeg mediainfo mencoder lame libvorbisenc2 libvorbisfile3 libx264-dev libvo-aacenc-dev libmp3lame-dev libopus-dev unzip
  4.  
  5. ADD THE NGINX REPOSITORY AND UPDATE
  6.  
  7.     sudo add-apt-repository ppa:nginx/stable
  8.     apt update
  9.  
  10. INSTALL NGINX
  11.  
  12.     sudo apt install nginx
  13.  
  14. INSTALL THE RTMP MODULE
  15.  
  16.     sudo apt install libnginx-mod-rtmp
  17.  
  18. CLONE THE RTMP GIT
  19.  
  20.     cd /usr/src
  21.     git clone https://github.com/arut/nginx-rtmp-module
  22.  
  23. COPY THE STAT.XSL FILE TO YOUR WEB FOLDER
  24.  
  25.     cp /usr/src/nginx-rtmp-module/stat.xsl /var/www/html/stat.xsl
  26.  
  27. CREATE A NEW FILE CALLED CROSSDOMAIN.XML IN YOUR WEB FOLDER
  28.  
  29.     nano /var/www/html/crossdomain.xml
  30.  
  31. PASTE THIS IN THE NEW FILE AND SAVE IT
  32.  
  33.     <?xml version="1.0"?>
  34.     <!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
  35.     <cross-domain-policy>
  36.     <allow-access-from domain="*"/>
  37.     </cross-domain-policy>
  38.  
  39. EDIT THE NGINX CONDIF FILE
  40.  
  41.     nano /etc/nginx/nginx.conf
  42.  
  43. AT THE END OF THE FILE ADD THIS
  44.  
  45. rtmp {
  46.         server {
  47.             listen 1935;
  48.             chunk_size 4096;
  49.  
  50.             application live {
  51.             live on;
  52.             record off;
  53.             interleave off;
  54.             wait_key on;
  55.             meta on;
  56.             wait_video off;
  57.             idle_streams off;
  58.             sync 300ms;
  59.             session_relay on;
  60.             #allow publish 127.0.0.1;
  61.             #allow publish 192.168.2.0/24;
  62.             allow publish all;
  63.             #deny publish all;
  64.             allow play all;    
  65.            
  66.             # EDIT THESE SO THE LIVESTREAM_KEY IS REPLACED BY YOUR PERSONAL KEY THAT YOU CAN LOOK UP ON THE SITE OF THE PLATFORM
  67.             # push rtmp://live-ams.twitch.tv/app/LIVESTREAM_KEY;
  68.             # push rtmp://a.rtmp.youtube.com/live2/LIVESTREAM_KEY;
  69.             # push rtmp://ingest-ams.mixer.com:1935/beam/LIVESTREAM_KEY;
  70.             }
  71.         }
  72. }
  73.  
  74. EDIT THE DEFAULT SITE CONFIG
  75.  
  76.     nano /etc/nginx/sites-enabled/default
  77.  
  78. SEARCH FOR THE FOLLOWING LINES:
  79.  
  80.     #location ~ /\.ht {
  81.     #   deny all;
  82.  
  83. AND DIRECTLY UNDER IT PASTE THE FOLLOWING
  84.  
  85.     location /stat {
  86.         rtmp_stat all;
  87.         rtmp_stat_stylesheet stat.xsl;
  88.     }
  89.     location /stat.xsl {
  90.         root /var/www/html/;
  91.     }
  92.     #location /control {
  93.     # you'll need a htpasswd auth file, that's outside the scope of this doc but any apache one will work
  94.     #   auth_basic "stream";
  95.     #   rtmp_control all;
  96.     #}
  97.  
  98. SO THAT IT WILL LOOK SOMETHING LIKE THIS AFTER PASTING:
  99.  
  100.  
  101.     # deny access to .htaccess files, if Apache's document root
  102.     # concurs with nginx's one
  103.     #
  104.     #location ~ /\.ht {
  105.     #   deny all;
  106.     #}
  107.  
  108.     location /stat {
  109.         rtmp_stat all;
  110.         rtmp_stat_stylesheet stat.xsl;
  111.     }
  112.     location /stat.xsl {
  113.         root /var/www/html/;
  114.     }
  115.     #location /control {
  116.     # you'll need a htpasswd auth file, that's outside the scope of this doc but any apache one will work
  117.     #   auth_basic "stream";
  118.     #   rtmp_control all;
  119.     #}
  120. }
  121.  
  122. # Virtual Host configuration for example.com
  123.  
  124. ------------------------------------------------------------
  125.  
  126. YOU ARE DONE SETTING UP THE SERVER. HAVE A LOOK AT THE WIKI FROM THE RTMP MODULE WEBPAGE TO LEARN HOW TO USE DIFFERENT VARIABLES TO FURTHER SET UP YOUR SERVER.  https://github.com/arut/nginx-rtmp-module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement