日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Nginx >内容正文

Nginx

Nginx流媒体支持配置

發布時間:2025/7/14 Nginx 59 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Nginx流媒体支持配置 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Nginx是一個短小精悍,且性能超強的Web服務器,同時也可以用作反向代理服務器以及郵件服務器。除此之外Nginx也可以用于搭建一個簡易的流媒體服務器。基于此,本文描述了在Nginx 1.8之上構建一個簡易的流媒體服務器,同時通過反向代理的方式將其代理至流媒體服務器。

有關Nginx相關的基礎知識
Linux 6下安裝編譯安裝Nginx
Nginx 概述及日常管理
Nginx基于IP,端口,域名配置虛擬主機
Linux 下配置nginx到php的連接

一、當前的運行環境及安裝文件

1、當前的運行環境 # more /etc/redhat-release CentOS release 6.5 (Final)# /u01/app/nginx/sbin/nginx -v nginx version: nginx/1.8.12、安裝文件下載 http://download.csdn.net/detail/robinson_0612/97389483、安裝文件位置 # pwd /u01/soft# ls yamdi-1.9.tar.gz nginx_mod_h264_streaming-2.2.7.tar.gz nginx-1.8.1

二、安裝及重新編譯Nginx

1、安裝yamdi # tar -xf yamdi-1.9.tar.gz # cd yamdi-1.9 # make && make installgcc -O2 -Wall yamdi.c -o yamdiinstall -m 0755 -o root yamdi /usr/local/bin2、安裝nginx_mod_h264_streaming # cd /u01/soft # tar -xf nginx_mod_h264_streaming-2.2.7.tar.gz # vim /u01/soft/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c###注釋掉158-161行157 /* TODO: Win32 */158 /* if (r->zero_in_uri)159 {160 return NGX_DECLINED;161 }162 */ ###否則出現如下錯誤 # make In file included from /usr/local/src/nginx_mod_h264_streaming-2.2.7/src/ngx_http_h264_streaming_module.c:2: /usr/local/src/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c: 在函數‘ngx_streaming_handler’中: /usr/local/src/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c:158: 錯誤: ‘ngx_http_request_t’沒有名為‘zero_in_uri’的成員 make[1]: *** [objs/addon/src/ngx_http_h264_streaming_module.o] 錯誤 1 make[1]: Leaving directory `/usr/local/src/nginx-1.8.1' make: *** [build] 錯誤 23、查看nginx當前已編譯的模塊以及添加模塊 # /u01/app/nginx/sbin/nginx -V nginx version: nginx/1.8.1 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) built with OpenSSL 1.0.1e-fips 11 Feb 2013 TLS SNI support enabled configure arguments: --prefix=/u01/app/nginx --sbin-path=/u01/app/nginx/sbin/nginx --conf-path=/u01/app/nginx/conf/nginx.conf --error-log-path=/u01/app/nginx/logs/error.log --http-log-path=/u01/app/nginx/logs/access.log --pid-path=/u01/app/nginx/nginx.pid --lock-path=/u01/app/nginx/nginx.lock --http-client-body-temp-path=/u01/app/nginx/tempcache/client_temp --http-proxy-temp-path=/u01/app/nginx/tempcache/proxy_temp --http-fastcgi-temp-path=/u01/app/nginx/tempcache/fastcgi_temp --http-uwsgi-temp-path=/u01/app/nginx/tempcache/uwsgi_temp --http-scgi-temp-path=/u01/app/nginx/tempcache/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_spdy_module --with-ipv6 ###將nginx_mod_h264_streaming模塊添加到nginx # cd /u01/soft/nginx-1.8.1 # ./configure \ --prefix=/u01/app/nginx --sbin-path=/u01/app/nginx/sbin/nginx \ --conf-path=/u01/app/nginx/conf/nginx.conf --error-log-path=/u01/app/nginx/logs/error.log \ --http-log-path=/u01/app/nginx/logs/access.log --pid-path=/u01/app/nginx/nginx.pid \ --lock-path=/u01/app/nginx/nginx.lock --http-client-body-temp-path=/u01/app/nginx/tempcache/client_temp \ --http-proxy-temp-path=/u01/app/nginx/tempcache/proxy_temp \ --http-fastcgi-temp-path=/u01/app/nginx/tempcache/fastcgi_temp \ --http-uwsgi-temp-path=/u01/app/nginx/tempcache/uwsgi_temp \ --http-scgi-temp-path=/u01/app/nginx/tempcache/scgi_temp --user=nginx --group=nginx \ --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module \ --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module \ --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module \ --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module \ --with-file-aio --with-http_spdy_module --with-ipv6 \ --add-module=/u01/soft/nginx_mod_h264_streaming-2.2.7 ###使用add-module添加模塊 # make# /u01/app/nginx/sbin/nginx -s stop # cp /u01/app/nginx/sbin/nginx /u01/app/nginx/sbin/nginx.bk.0116### 替換nginx 二進制文件 # cp /u01/soft/nginx-1.8.1/objs/nginx /u01/app/nginx/sbin/nginx# service nginx start Starting nginx: [ OK ]# /u01/app/nginx/sbin/nginx -V nginx version: nginx/1.8.1 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) built with OpenSSL 1.0.1e-fips 11 Feb 2013 TLS SNI support enabled configure arguments: --prefix=/u01/app/nginx ................ --add-module=/u01/soft/nginx_mod_h264_streaming-2.2.7

三、Nginx配置文件摘錄(供參考)

### Nginx配置文件 # more /u01/app/nginx/conf/nginx.conf worker_processes 8; user nobody;error_log /u01/app/nginx/logs/error.log;events {use epoll;worker_connections 65535;multi_accept on; }http {include mime.types;default_type application/octet-stream;charset utf-8;log_format main '$remote_addr [$time_local] "$host $request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';server_names_hash_bucket_size 128;client_header_buffer_size 64k;client_max_body_size 50m;client_body_buffer_size 512k;large_client_header_buffers 4 64k;server_tokens off;sendfile on;tcp_nopush on;tcp_nodelay on;keepalive_timeout 10;ssl_session_cache shared:SSL:50m;ssl_session_timeout 5m;proxy_connect_timeout 5;proxy_read_timeout 60;proxy_send_timeout 5;proxy_buffer_size 16k;proxy_buffers 4 64k;proxy_busy_buffers_size 128k;proxy_temp_file_write_size 128k;proxy_temp_path /u01/app/nginx/tempcache/proxy_temp;proxy_cache_path /u01/app/nginx/tempcache/proxy_cache_dir levels=1:2 keys_zone=cache_one:2000minactive=10d max_size=30g;gzip on;gzip_min_length 1k;gzip_buffers 4 16k;gzip_comp_level 6;gzip_types text/plain text/css text/xml text/javascript application/json application/x-javascript application/xml application/xml+rss;open_file_cache max=204800 inactive=20s; open_file_cache_min_uses 2; open_file_cache_valid 30s; open_file_cache_errors on;include conf.d/*.conf; } # more /u01/app/nginx/conf/conf.d/stream.conf server {listen 9091;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / {root /u02/upload_video;index index.html index.htm;}#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;} }###反向代理端的配置 # /opt/nginx/sbin/nginx -v nginx version: nginx/1.5.13 # more /opt/nginx/conf/conf.d/http-www.conf upstream stream_srv {server 10.24.249.21:9091 max_fails=3 fail_timeout=30s;keepalive 32; }server {listen 80;server_name www.abc.com;access_log /log/nginx/http-access.log;error_log /log/nginx/http-error.log;location /stream {proxy_set_header Host $host;proxy_set_header x-for $remote_addr;proxy_set_header x-server $host;proxy_set_header x-agent $http_user_agent;proxy_pass http://stream_srv;} }###測試 http://www.abc.com/stream/test.mp4

四、Nginx模塊動態增加

NGINX 1.9.11開始增加加載動態模塊支持,從此不再需要替換nginx文件即可增加第三方擴展。 目前官方只有幾個模塊支持動態加載,第三方模塊需要升級支持才可編譯成模塊。# ./configure --help | grep dynamic--with-http_xslt_module=dynamic enable dynamic ngx_http_xslt_module--with-http_image_filter_module=dynamic enable dynamic ngx_http_image_filter_module--with-http_geoip_module=dynamic enable dynamic ngx_http_geoip_module--with-mail=dynamic enable dynamic POP3/IMAP4/SMTP proxy module--with-stream=dynamic enable dynamic TCP proxy module--add-dynamic-module=PATH enable dynamic external module如上可看出官方支持5個動態模塊編譯,需要增加第三方模塊,使用參數--add-dynamic-module=即可。NGINX動態模塊語法,此配置方法和Apache httpd大同小異load_moduleDefault: —配置段: main說明:版本必須>=1.9.11示例:load_module modules/ngx_mail_module.so;

總結

以上是生活随笔為你收集整理的Nginx流媒体支持配置的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。