码迷,mamicode.com
首页 > 其他好文 > 详细

Nginx 自带模块构建流媒体服务

时间:2018-07-25 22:42:54      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:linux   lis   ges   bre   remote   主机名   mp4   test   har   

                                              

              Nginx 部署流媒体服务

 

Nginx 平滑升级 

参考地址

http://zhangge.net/4856.html

 

主机名

IP地址

Ngin版本

系统版本

备注

Nginx-Streaming-media

192.168.1.180

nginx/1.9.4

Cenots6.6

V1

 

1.软件依赖环境
yum –y install  gcc* make GeoI GeoIP-data GeoIP-devel  zlib zlib-devel openssl openssl-devel libxml2 libxml2-devel libxslt libxslt-devel  gd  gd-devel pcre-devel pcre
 
注释: # Libxml2是个C语言的XML程式库,能简单方便的提供对XML文件的各种操作,并且支持XPATH查询,及部分的支持XSLT转换等功能!
未安装GeoI GeoIP-data GeoIP-devel gd-devel  依赖包会出现
#编译出现以下报错信息;
出现./configure: error: the HTTP image filter module requires the GD library.
You can either do not enable the module or install the libraries.
2. NGINX源码包安装;
1.在线下载官方软件
wget  http://nginx.org/download/nginx-1.9.4.tar.gz
tar xf  nginx-1.*.tar.gz  -C  /usr/local/src
cd  /usr/local/ nginx-1.9.4

2.添加编译详细参数;
./configure --prefix=/usr/loal/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_spdy_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_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_degradation_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --http-client-body-temp-path=$nginx_tmp/client --http-proxy-temp-path=$nginx_tmp/proxy --http-fastcgi-temp-path=$nginx_tmp/fcgi --http-uwsgi-temp-path=$nginx_tmp/uwsgi --http-scgi-temp-path=$nginx_tmp/scgi  --with-pcre
make && make install


3.NGINX核心配置部分
## nginx main configure file
user nginx nginx;
#worker_processes _PROCESSES;
worker_priority -10;
worker_rlimit_nofile 51200;
error_log  _ERROR_LOG error; 
pid        /var/run/nginx.pid;
#access_log off;
#access_log /var/log/nginx/access.log combined; 
events {
  use epoll;
    worker_connections  51200;
}
http {
include       /etc/nginx/mime.types;
default_type  application/octet-stream;
charset utf-8;
 
server_tokens   off;
server_names_hash_bucket_size 256;
 client_header_buffer_size 256k;
 large_client_header_buffers 4 256k;
client_max_body_size 50m;
client_body_buffer_size 256k;
 client_header_timeout 3m;
 client_body_timeout 3m;
sendfile       on;
tcp_nopush     on;
keepalive_timeout  120;
 tcp_nodelay on;
 gzip on;
gzip_min_length 1k;
  gzip_buffers     4 16k;
  gzip_http_version 1.0;
  gzip_comp_level 2;
    gzip_types       text/plain application/x-javascript text/css application/xml;
    gzip_vary on;
    gzip_disable "MSIE [1-6]\.";
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    include nginx_cache/*.conf;
} 
server {
        listen       80;
       server_name  www.test123.com;
       charset  utf-8;
       access_log  /var/log/nginx/host.access.log  main;
    location / {
         root /home/medio/project/;
         index  index.html index.htm;
      }
     location ~ .*\.(mp4|jpg)$             
         {
             root /home/medio/project/;
              limit_rate_after 500k;
              limit_rate 128k;
              expires 30d; 
        valid_referers none blocked www.breaklinux.com breaklinux.com *.test123.com;
            if ($invalid_referer) {
                    rewrite ^/ http://www.test123.com/retrun.html;
                 return 403;
            }
          }
      
}
server {
  listen 80;
  server_name    www.wenjian123.com;
  root /home/medio/test;
  index index.html;
}
 
4. 测试流媒体服务;
上传MP4格式视频文件。放置nginx索引目录下;访问如下;


技术分享图片

Nginx 自带模块构建流媒体服务

标签:linux   lis   ges   bre   remote   主机名   mp4   test   har   

原文地址:http://blog.51cto.com/breaklinux/2150193

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!