_nginx_nginx-HTTP-FLV-モジュールを構築するために2019から2、CentOS7_ Liveサービス

1.はじめに

nginxの-HTTP-FLV-モジュールは、に基づいて開発されたライブのnginx-RTMPモジュール内のモジュールです。
Arutはnginxの-RTMPモジュールを作成ありがとう、それは、サポートRTMP nginxのは、生きるために使用することができ、優れたサードパーティモジュールで、HLSとDASHの道を生き、また、コールのサードパーティ製のソフトウェアトランスコーディング、ビデオ録画などの機能をサポートしていますnginxのに頼っているため、パフォーマンスが比較的高いです。しかし、軟膏で飛ぶには、このような最初の画面に長い時間のような場所の多くは、生きるためにHTTP-FLVの方法をサポートしていない、仮想ホスト(バーチャルホスト)機能をサポートしていない、接続構成を聞き省略されて受け入れることができない、多くの明白なバグやその他の問題があります。
nginxの-HTTP-FLV-モジュールは、上記の問題を解決します。もちろん、いくつかのバグがまだ修理する必要があります。特定の使用のマニュアルを参照してください。

なぜライブHTTP-FLVウェイサーバーのサポートなど、nginxの?nginxのWebサーバー機能は非常によく、HTTPプロトコルをサポートしているため、優れた性能Nginxは、テストシナリオの多くの後。また、サードパーティ製のソフトウェアにあまり依存nginxの自体は、非常に簡単に展開します。これらはすべて、そのライブサーバーのHTTP-FLV方式まれな選択肢となっています。

1.1 nginxの-HTTP-FLV-モジュール機能

  • nginxの-RTMPモジュールは、に基づいてすべての機能と互換性があるのnginx-RTMPモジュールストリーミングメディアサーバー。
  • 生きるためにHTTP-FLVの方法をサポートしています
  • 時間に最初の画面を低減するためのGOPのサポートキャッシュ
  • サポートのホスティング機能
  • そのCIを省略するものとする基本的な機能に影響を与えずに聴くことができます
  • 修理nginxの-RTMPモジュール既知のバグ

1.2 nginxの-HTTP-FLV-モジュールのインストール構成

GitHubの:nginxの-HTTP-FLV-モジュール

https://github.com/winshining/nginx-http-flv-module

完全な説明文書を読む:英語README

1.3特長

機能 nginxの-HTTP-FLV-モジュール nginxの-RTMPモジュール リマーク
HTTP-FLV(遊び) バツ サポートHTTPS-FLVと応答をチャンク
GOPキャッシュ バツ
ウェブホスティング バツ
省略listen設定 備考を参照してください。 コンフィギュレーションが存在する必要がありますlisten
オーディオサポート 備考を参照してください。 wait_videoそれともwait_key開いた後に動作しません
定期的な印刷アクセスレコード バツ
JSON形式のSTAT バツ
  • nginxののバージョンがなければならない、不明の他のバージョンとの互換性1.2.6よりも大きいです。
  • Linuxの(推奨)/ FreeBSDの/ MacOSの/ Windowsの(限られました)
  • 支持的播放器VLC(RTMP&HTTP-FLV)/ OBS(RTMP&HTTP-FLV)/ JWプレーヤー(RTMP)/ flv.js(HTTP-FLV)。
  • flv.jsのみのサポートで実行するメディアソース拡張機能、ブラウザ上

1.4環境に依存

  • Unixシステムでは、あなたは、GNU makeを必要とするソフトウェアをコンパイルするコンパイラを呼び出します。

  • UNIXシステムでは、GCCが必要です。またはWindows上で、ソフトウェアをコンパイルするために使用され、MSVCが必要です。

  • Unixシステムでは、あなたがソフトウェア(オプション)をデバッグするために、GDBが必要です。

  • FFmpegのか、OBSは、メディアストリームをパブリッシュするために使用しました。

  • VLC(推奨)またはflv.js(推奨)は、ストリーミングメディアを再生するために使用しました。

  • nginxのは、正規表現をサポートする場合は、必要なPCREライブラリを

  • あなたが暗号化されたアクセスをサポートしたい場合はnginxのは、必要とOpenSSLライブラリを

  • あなたが圧縮をサポートしたい場合はnginxのは必要ではzlibライブラリを

2インストール

2.1 RHEL / CentOSの6、7

これらのオペレーティングシステムでは、最新の安定版Nginxは適応モジュールの最新リリースは、以下の方法で入手できます。

yum install https://extras.getpagespeed.com/release-el$(rpm -E %{rhel})-latest.rpm
yum install nginx-module-flv

2.2 RHEL 8

dnf install https://extras.getpagespeed.com/release-el$(rpm -E %{rhel})-latest.rpm
sudo dnf --disablerepo=rhel-8-for-x86_64-appstream-rpms install nginx-module-flv

インストール後、HTTP-FLV機能プロファイルhttp-flv.confとRTMPの機能プロファイルがrtmp.conf置かれる/etc/nginx/http-flvことで、ディレクトリにinclude手動に追加/etc/nginx/nginx.confRTMPおよびHTTP-FLVの機能を開くために、:

    http {
        ...
        include /etc/nginx/http-flv/http-flv.conf;
    }

    include /etc/nginx/http-flv/rtmp.conf;

次の設定を追加し/etc/nginx/nginx.conf、このモジュールを有効にするには、nginxのを起動または再起動します。

load_module modules/ngx_http_flv_live_module.so;

2.3注意

上述の構成はされなければならない位置eventsさもなければnginxのが起動し、設定項目の前に。

更新が可能yum updateに行うこと。その他の詳細については、nginxのモジュールが表示さGetPageSpeed

他のオペレーティングシステムについては、インストールソースのコンパイラの下の注を参照。

3ソースのコンパイラのインストール

3.1注意

nginxの-HTTP-FLV-モジュールが含まれているnginxの-RTMPモジュールのすべての機能のために、そうしていないのnginx-HTTP-FLV-モジュールとなりnginxの-RTMPモジュール一緒にコンパイル。

Windows上の3.2

コンパイルのステップを参照してくださいのVisual CでのWin32プラットフォーム上でnginxので建物のことを忘れないでください、Run configure scriptステップを追加します--add-module=/path/to/nginx-http-flv-module

Linuxシステム上の3.3

ダウンロードのnginxとnginxの-HTTP-FLV-モジュールを。

パス/パス/に/ nginxの-HTTP-FLV-モジュールにそれらを解凍します。

オープンソースのnginxのパス(/ usr / local / nginxの)と実行:

コンパイルされたモジュールnginxのは、は/ usr / local / nginxのに行きます

    ./configure --add-module=/path/to/nginx-http-flv-module
    make
    make install

若しくは

モジュールは、動的モジュールとしてコンパイルされています
    ./configure --add-dynamic-module=/path/to/nginx-http-flv-module
    make
    make install

操作ログ

[root@ip104 tengine-2.3.2]# ./configure --add-dynamic-module=/path/to/nginx-http-flv-module
checking for OS
 + Linux 3.10.0-957.21.3.el7.x86_64 x86_64
checking for C compiler ... found
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

[root@ip104 tengine-2.3.2]# 

4使用

nginx-RTMPモジュールの使用方法の詳細を参照してくださいREADME.mdを

4.1つぶやきストリーミングサービス

簡単にするために、トランスコーディングなし:

ffmpeg -re -i MEDIA_FILE_NAME -c copy -f flv rtmp://example.com[:port]/appname/streamname

4.2注意

  • 一部の古いバージョンのFFmpegは、オプションをサポートしていません。-c copyあなたは、オプションを使用することができ、-vcodec copy -acodec copy代わりに。

  • appnameブロックアプリケーションブロック(以下でより詳細)を一致させるためのRTMP構成。

  • streamname無料で指定するが、することはできません省略すること。

  • RTMPのデフォルトのポートはある1935あなたが別のポートを使用したい場合は、指定する必要があり、:port

4.3プレイ

HTTP-FLVの道

http://example.com[:port]/dir?[port=xxx&]app=appname&stream=streamname

4.4注意

  • あなたが使用している場合はffplayストリーミングのコマンドラインの再生を、そしてあなたがしなければならないそうでない場合は、URLパラメータは破棄され、上記URLに引用符を追加します(一部ではないので、スマートなシェルだろう「&」「背景」など)。

  • あなたが使用している場合はflv.jsがストリームを再生するので、その後、正しいコーディングストリームがリリースされていることを確認してくださいflv.jsが唯一のH.264でエンコードされたビデオとAAC / MP3エンコードされたオーディオをサポートしています

  • パラメータdirブロックの位置を一致させるための(以下でより詳細)HTTP構成ブロック。

  • デフォルトのHTTPポートがある80あなたが別のポートを使用する場合は、指定する必要があり、:port

  • RTMPのデフォルトのポートはある1935あなたが別のポートを使用する場合は、指定する必要があり、port=xxx

  • パラメータapp値(APPNAME)は、アプリケーションブロックを一致させるために使用されるが、要求があればapp、サーバーの複数のブロック中に存在し、これらのブロックは、同じサーバーのアドレスとポート構成を有し、ホスト名を使用する必要が一致するserver_name構成要素を区別するために要求さどのアプリケーションブロック。そうでない場合、アプリケーションは最初のブロックに一致します。

  • パラメータstream(さstreamName)の値は、ストリームの試合の名を解放します。

仮定すると、httpコンフィギュレーション・ブロックのlisten設定項目をされています。

http {
    ...
    server {
        listen 8080; #不是默认的80端口
        ...

        location /live {
            flv_live on;
        }
    }
}

rtmp構成ブロックlisten設定項目は以下のとおりです。

rtmp {
    ...
    server {
        listen 1985; #不是默认的1935端口
        ...

        application myapp {
            live on;
        }
    }
}

ストリームの名前が発行されるとmystream、その後、URLのHTTPは、プレイに基づいています。

http://example.com:8080/live?port=1985&app=myapp&stream=mystream

注意を払います

いくつかのプレイヤーがHTTPトランスポート・ブロックをサポートしていないので、この場合には最高のは、指定されたflv_live on;指定された場所でchunked_transfer_encoding off、それ以外の場合は、再生するために失敗します。

RTMPの道

rtmp://example.com[:port]/appname/streamname

HLSの道

http://example.com[:port]/dir/streamname.m3u8

DASHの道

http://example.com[:port]/dir/streamname.mpd

サンプル写真

RTMP(JWプレーヤー)&HTTP-FLV(VLC

RTMP&HTTP-FLV

HTTP-FLV(flv.js

HTTP-FLV

例nginx.conf

注意を払います

設定項目rtmp_auto_pushrtmp_auto_push_reconnectおよびrtmp_socket_dirマルチプロセスモデルがあるため、17063のWindows 10を除いて以降、Windows上で動作しないrelayUNIXドメインソケットをサポートするために必要。を参照してくださいWindowsの10上のUNIXドメインソケット

最適な構成項目はworker_processesマルチプロセスモードでは、ので、1に設定されているngx_rtmp_stat_moduleHTTP要求がランダムにワーカープロセスに割り当てられていたことから、指定されたワーカープロセスからの統計情報を取得することはできません。ngx_rtmp_control_moduleまた、我々は同じ問題を抱えています。この問題は、このパッチを介し得るごとの労働者・リスナーの最適化。

また、vhost機能は完全に修理を待って、マルチプロセスモードで正しく実行することはできません。例えば、関係なく、流れをプラグするドメインの、マルチプロセスモードで次の設定は問題ありません。

rtmp {
    ...
    server {
        listen 1935;
        server_name 1st_domain_name;

        application myapp {
            ...
        }
    }

    server {
        listen 1935;
        server_name 2nd_domain_name;

        application myapp {
            ...
        }
    }
}

出版社の出版メディアはポート1945上でのストリーミング次のような構成では、このポート上のワーカープロセスの非出版社への再生要求へのアクセスには問題があります:

rtmp {
    ...
    server {
        listen 1935;
        server_name 1st_domain_name;

        application myapp {
            ...
        }
    }

    server {
        listen 1945;
        server_name 2nd_domain_name;

        application myapp {
            ...
        }
    }
}

設定例

worker_processes  1; #运行在Windows上时,设置为1,因为Windows不支持Unix domain socket
#worker_processes  auto; #1.3.8和1.2.5以及之后的版本

#worker_cpu_affinity  0001 0010 0100 1000; #只能用于FreeBSD和Linux
#worker_cpu_affinity  auto; #1.9.10以及之后的版本

error_log logs/error.log error;

#如果此模块被编译为动态模块并且要使用与RTMP相关的功
#能时,必须指定下面的配置项并且它必须位于events配置
#项之前,否则NGINX启动时不会加载此模块或者加载失败

#load_module modules/ngx_http_flv_live_module.so;

events {
    worker_connections  4096;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    keepalive_timeout  65;

    server {
        listen       80;

        location / {
            root   /var/www;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        location /live {
            flv_live on; #打开HTTP播放FLV直播流功能
            chunked_transfer_encoding on; #支持'Transfer-Encoding: chunked'方式回复

            add_header 'Access-Control-Allow-Origin' '*'; #添加额外的HTTP头
            add_header 'Access-Control-Allow-Credentials' 'true'; #添加额外的HTTP头
        }

        location /hls {
            types {
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }

            root /tmp;
            add_header 'Cache-Control' 'no-cache';
        }

        location /dash {
            root /tmp;
            add_header 'Cache-Control' 'no-cache';
        }

        location /stat {
            #push和pull状态的配置

            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }

        location /stat.xsl {
            root /var/www/rtmp; #指定stat.xsl的位置
        }

        #如果需要JSON风格的stat, 不用指定stat.xsl
        #但是需要指定一个新的配置项rtmp_stat_format

        #location /stat {
        #    rtmp_stat all;
        #    rtmp_stat_format json;
        #}

        location /control {
            rtmp_control all; #rtmp控制模块的配置
        }
    }
}

rtmp_auto_push on;
rtmp_auto_push_reconnect 1s;
rtmp_socket_dir /tmp;

rtmp {
    out_queue           4096;
    out_cork            8;
    max_streams         128;
    timeout             15s;
    drop_idle_publisher 15s;

    log_interval 5s; #log模块在access.log中记录日志的间隔时间,对调试非常有用
    log_size     1m; #log模块用来记录日志的缓冲区大小

    server {
        listen 1935;
        server_name www.test.*; #用于虚拟主机名后缀通配

        application myapp {
            live on;
            gop_cache on; #打开GOP缓存,减少首屏等待时间
        }

        application hls {
            live on;
            hls on;
            hls_path /tmp/hls;
        }

        application dash {
            live on;
            dash on;
            dash_path /tmp/dash;
        }
    }

    server {
        listen 1935;
        server_name *.test.com; #用于虚拟主机名前缀通配

        application myapp {
            live on;
            gop_cache on; #打开GOP缓存,减少首屏等待时间
        }
    }

    server {
        listen 1935;
        server_name www.test.com; #用于虚拟主机名完全匹配

        application myapp {
            live on;
            gop_cache on; #打开GOP缓存,减少首屏等待时间
        }
    }
}
events {
    worker_connections  1024; #Nginx处理的最大连接数
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    keepalive_timeout  65;

    server {
        listen       80; #Nginx监听的HTTP请求端口

        location / {
            root   /var/www; #HTTP请求URL映射到服务器的位置
            index  index.html index.htm; #HTTP请求优先请求的文件,如http://localhost/,如果有index.html在/var/www目录下,那么请求的是/var/www/index.html
        }

        error_page   500 502 503 504  /50x.html; #如果遇到这些HTTP请求错误,Nginx返回50x.html的内容
        location = /50x.html {
            root   html; #因为/配置了root /var/www,所以这儿html对应的是/var/www/html,所以50x.html的路径是/var/www/html/50x.html
        }

        location /live {
            flv_live on; #当HTTP请求以/live结尾,匹配这儿,这个选项表示开启了flv直播播放功能
            chunked  on; #HTTP协议开启Transfer-Encoding: chunked;方式回复,已废弃,使用标准的chunked_tranfer_encoding代替
        }
    }
}

rtmp_auto_push on; #因为Nginx可能开启多个子进程,这个选项表示推流时,媒体流会发布到多个子进程
rtmp_auto_push_reconnect 1s;
rtmp_socket_dir /tmp; #多个子进程情况下,推流时,最开始只有一个子进程在竞争中接收到数据,然后它再relay给其他子进程,他们之间通过unix domain socket传输数据,这个选项表示unix domain socket的路径

rtmp {
    out_queue   4096;
    out_cork    8;
    max_streams 64; #Nginx能接受的最大的推流数

    server {
        listen 1935; #Nginx监听的RTMP推流/拉流端口,可以省略,默认监听1935

        application myapp {
            live on; #当推流时,RTMP路径中的APP(RTMP中一个概念)匹配myapp时,开启直播
            gop_cache on; #开启GOP(Group of Picture)缓存,播放器解码时,收到一个完整的GOP才会开始播放,这个是减少播放延迟的选项
            pull rtmp://live.hkstv.hk.lxdns.com/live/hks; #如果懒得推流,那可以用这个,香港卫视的直播推流

        }

        #以下配置项已废弃

        application app1 {

            proxy_pass rtmp://host(ip or domain name)[:host]/app2; #将推流反向代理到上游服务器,并将app1自动转化为app2

            #proxy_pass rtmp://backend; #将推流反向代理到上游服务器,见upstream配置

        }
    }

    server {

        listen 1935;

        server_name *.test.com; #或者www.test.*/www.test.com

        application myapp {

            live on;

            gop_cache on;

        }

    }

    #以下配置项已废弃,原因在下文更新中

    upstream backend {

        #开启负载均衡

        server host1:port1;

        server host2:port2;

    }
}

基本設定が完了し、何が自分のプロフィールです

#aaa
#工作进程
worker_processes  2;
#worker_processes  auto; #1.3.8和1.2.5以及之后的版本

#worker_cpu_affinity  0001 0010 0100 1000; #只能用于FreeBSD和Linux
#worker_cpu_affinity  auto; #1.9.10以及之后的版本

#日志功能
error_log logs/error.log error;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#error_log  "pipe:rollback logs/error_log interval=1d baknum=7 maxsize=2G";

#pid        logs/nginx.pid;
#如果此模块被编译为动态模块并且要使用与RTMP相关的功
#能时,必须指定下面的配置项并且它必须位于events配置
#项之前,否则NGINX启动时不会加载此模块或者加载失败

#load_module modules/ngx_http_flv_live_module.so;

#事件配置
events {
    worker_connections  1024;
}

# load modules compiled as Dynamic Shared Object (DSO)
#
#dso {
#    load ngx_http_fastcgi_module.so;
#    load ngx_http_rewrite_module.so;
#}
#RTMP配置

rtmp_auto_push on;
rtmp_auto_push_reconnect 1s;
rtmp_socket_dir /tmp;

rtmp {
    out_queue           4096;
    out_cork            8;
    max_streams         128;
    timeout             15s;
    drop_idle_publisher 15s;

    log_interval 5s; #log模块在access.log中记录日志的间隔时间,对调试非常有用
    log_size     1m; #log模块用来记录日志的缓冲区大小
    
    # 用于是直播的服务 1935端口 推送地址:rtmp://39xxxxxxx.120:1935/hls  获取地址:http://live.xxxxxxxx.com/hls/222.m3u8
    server {
        listen 1935;
        server_name live.xxxxx.com;
        #server_name 1935.xxxxxx.com; #用于虚拟主机名后缀通配
        #chunk_size 4000; #快大小
        
        #电视模式
        application mytv {          
            live on;   #enable live streaming
            #record first 1K of stream
            record all;
            record_path /tmp/av;
            record_max_size 1K;
            #append current timestamp to each flv
            record_unique on;
            #publish only from localhost
            allow publish 127.0.0.1;
            deny publish all;
            #allow play all;
        }
        application myapp {
            live on;
            gop_cache on; #打开GOP缓存,减少首屏等待时间
        }
        #hls配置
        application hls {
            live on;
            hls on;
            hls_path /tmp/hls;
        }
        application dash {
            live on;
            dash on;
            dash_path /tmp/dash;
        }
    }
    #可以多个server的 
     
}  


# HTTP 相关网络请求配置
http {
    include       mime.types;
    default_type  application/octet-stream;
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    #access_log  "pipe:rollback logs/access_log interval=1d baknum=7 maxsize=2G"  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
    # 用于,net core 相关网站的服务    
    server {
        listen       80;
        server_name www.xxxxxxxx.com
        #server_name   xxxxxx.com  *.xxxxxxx.com;
           
        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        #access_log  "pipe:rollback logs/host.access_log interval=1d baknum=7 maxsize=2G"  main;
        location / {
            root   html;
            index  index.html index.htm;
                       
           #proxy_pass         http://localhost:5000;
           #proxy_http_version 1.1;
           #proxy_set_header   Upgrade $http_upgrade;
           #proxy_set_header   Connection keep-alive;
           #proxy_set_header   Host $host;
           # proxy_cache_bypass $http_upgrade;
           #proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
           #proxy_set_header   X-Forwarded-Proto $scheme;
        }
        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

    #用于视频直播服务先关的http 解析服务 add 2019-7-8
    server {
        listen      80;
        server_name live.xxxxxxxxxx.com;
     
        location / {
            
            
            #index  /stat;
            proxy_pass         http://localhost:1936;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        location /live {
            flv_live on; #打开HTTP播放FLV直播流功能
            chunked_transfer_encoding on; #支持'Transfer-Encoding: chunked'方式回复
            add_header 'Access-Control-Allow-Origin' '*'; #添加额外的HTTP头
            add_header 'Access-Control-Allow-Credentials' 'true'; #添加额外的HTTP头
        }

        location /hls {
            types {
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }

            root /tmp;
            add_header 'Cache-Control' 'no-cache';
        }

        location /dash {
            root /tmp;
            add_header 'Cache-Control' 'no-cache';
        }

        location /stat {
            #push和pull状态的配置

            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }

        location /stat.xsl {
            root /usr/local/nginx-http-flv-module; #指定stat.xsl的位置
        }

        #如果需要JSON风格的stat, 不用指定stat.xsl
        #但是需要指定一个新的配置项rtmp_stat_format

        #location /stat {
        #    rtmp_stat all;
        #    rtmp_stat_format json;
        #}

        location /control {
            rtmp_control all; #rtmp控制模块的配置
        }
    }
    
     #测试服务器使用
     server {
        listen       80;
        server_name  8056.xxxxxxxxxxx.com;
        #server_name   1123.xxxxxxxx.com;
           
        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        #access_log  "pipe:rollback logs/host.access_log interval=1d baknum=7 maxsize=2G"  main;
        location / {
            root   html;
            index  404.html 404.htm;
                       
           proxy_pass         http://localhost:8056;
           #proxy_http_version 1.1;
           #proxy_set_header   Upgrade $http_upgrade;
           #proxy_set_header   Connection keep-alive;
           #proxy_set_header   Host $host;
           # proxy_cache_bypass $http_upgrade;
           #proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
           #proxy_set_header   X-Forwarded-Proto $scheme;
        }
        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}


    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}     

}

おすすめ

転載: www.cnblogs.com/sopcce/p/11621162.html