Nginx configuration Rtmp Server for rtmp and HLS live

Source: Internet
Author: User
Tags sendfile
Introduction to my Nginx usage

First on configuration:

work_processes4; events{work_connections1024x768;} http{includeMime.types;Default_typeApplication/octet-stream;Sendfile on;Keepalive_timeout $; server{Listen the;server_namelocalhost Location/{RoothtmlInsexIndex.html index.htm; } Location/hls{alias/tmp/app; }Error_page -502503504/50x.html; Location=/50x.html{Roothtml }}}rtmp{server{Listen1935;chunk_size4000;Applicationliaortmp{Live on; }Applicationhls{Live on;HLS on;Hls_path/tmp/app;hls_frament15s; }        }    }

Interpretation of the configuration


    • Workprocesses and Work_connections

Work_processes: The START process, usually set to the number of CPUs equal.
Work_connections: Maximum number of concurrent links for a single background worker process session

  • HTTP Server configuration

    • sendndfile: Specifies whether Nginx calls the Sendfile function (zero copy mode) to output the file, and for normal applications, it must be set to On, if used for downloading applications such as disk IO heavy load applications, can be set to off to balance disk and network I/O processing speed, reduce system uptime.
    • Keepalive_timeout: Connection time-out
    • Server
      • listen: Configure which port to listen
      • server_name: Define the use of XXX access, that is, the IP domain name
      • loaction/: Default Request
      • Error_page and immediately following location: Define error page
      • Location/hls: Define request HLS, I am declaring here that if the request HLS stream is to be appended to the playback address M3 U8,hls slices from the/tmp/ app , which the app defines for itself
  • Configuration of rtmp push-streaming server
    • Listen: Listening port
    • Application liaortmp: Configuring rtmp normal push Flow request here
    • Application Liaohls: Configure the rtmp push flow request here, play in HLS mode, slice in/tmp/ app , where it corresponds exactly to the HTTP configuration above, what the app writes here, and what it writes at http
      • Live on: Toggle Live mode, which is a one-to-many broadcast
      • HLS on: Switch HLS in application
      • Hls_path: Slice Storage Address
      • Hls_fragment: Slice size, set HLS segment length, default is 5 seconds

  • At this point, the simple configuration of Nginx has been completed, the/usr/local/conf/nginx.conf is stored in the above configuration.


      • Give an example (about app )
    • RTMP push streaming and rtmp playback
      • Push Stream Address: Rtmp://x.x.x.x:1935/liaortmp/liao
      • Play Address: Rtmp://x.x.x.x:1935/liaortmp/liao
    • RTMP push Stream and HLS live
      • Push Stream Address: Rtmp://x.x.x.x:1935/liaohls/liao
      • Play Address: Rtmp://x.x.x.x:80/hls/liao

      liaois arbitrary that can be replaced.

    Reference
    1. Nginx Configuration File Detailed description
    2. Nginx RTMP Module Nginx-rtmp-module instruction detailed

    The above describes the Nginx configuration Rtmp server to implement RTMP and HLS live, including aspects of the content, I hope the PHP tutorial interested in a friend helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.