nginx+tomcat+二级域名静态文件分离支持mp4视频播放配置实例

二级域名配置

在/etc/nginx/conf.d/目录下配置二级域名同名的conf文件,路径改成对应的即可
statics.xxxxx.com.conf
server {
listen ;
server_name statics.xxxxx.com ;
access_log /var/log/nginx/access_statics.xxxxx.com.log;
error_log /var/log/nginx/error_statics.xxxxx.com.log;
root /home/www/statics;
index index.html index.htm; location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
expires 30d;
}
location ~ .*\.(js|css)?$ {
expires 7d;
}
location /video/ {
mp4;
mp4_buffer_size 4m;
mp4_max_buffer_size 10m;
}
}

支持mp4视频格式在 location /video/ 这个配置里。

---------------------------------

nginx配置:

# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf; events {
worker_connections 1024;
} http {
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 /var/log/nginx/access.log main; sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048; include /etc/nginx/mime.types;
default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
}

------------------------------

主域名转发到tomcat配置,端口号自己改:

server {
listen ;
server_name localhost; location / {
client_max_body_size 10m;
index index.html index.htm index.jsp;
proxy_set_header Host $host;
proxy_pass_header User-Agent;
proxy_pass http://localhost:8089/; } error_page /.html;
location = /40x.html {
} error_page /50x.html;
location = /50x.html {
} }

测试视频html,视频文件要放在同一目录下:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>测试视频</title>
</head>
<body>
<video width="520" height="540" controls autoplay="autoplay">
<source src="test.mp4" type="video/mp4" >
</video>
</body>
</html>

-------------------------------
nginx+tomcat转发的,域名是在那里配置的了?
在tomcat的server.xml里面也是用<Host name="localhost" 没看到配置域名的
listen 80;
server_name localhost;
localhost就是域名
相当于这个是默认主机 所有解析到这台的 都会跑到这里去了
相当于所有域名只要解析到这台ip来 就会直接跑到这里来了

ping下看解析 和你现在的云主机是同个ip?
是同一IP,那就是没走slb

nginx+tomcat+二级域名静态文件分离支持mp4视频播放配置实例的更多相关文章

  1. Nginx +Tomcat 实现动静态分离(转)

    Nginx +Tomcat 实现动静态分离 动静态分离就是Nginx处理客户端的请求的静态页面(html页面)或者图片,Tomcat处理客户端请求的动态页面(jsp页面),因为Nginx处理的静态页面 ...

  2. Nginx+Tomcat负载均衡、动静分离群集

    Nginx+Tomcat负载均衡.动静分离群集 目录 Nginx+Tomcat负载均衡.动静分离群集 一.Tomcat 1. Tomcat简介 2. Tomcat重要目录 二.Nginx负载均衡原理 ...

  3. nginx + tomcat 单个域名及多个域名的配置

    //nginx + tomcat 单个域名及多个域名的配置//修改nginx的配置文件,linux默认路径 /usr/local/nginx/conf/nginx.conf //prot为8082的w ...

  4. NGINX不允许向静态文件提交POST方式的请求,否则报405错误(apache中没有出现)

    telnet *.*.*.* 80POST /map/navigation/2011winter/jsn/jsn_20120723_pack/pvf.jsnHTTP/1.1Host:*.*.*.* ( ...

  5. Nginx中的root&alias文件路径及索引目录配置详解

    这篇文章主要介绍了Nginx中的root&alias文件路径及索引目录配置,顺带讲解了root和alias命令的用法,需要的朋友可以参考下     root&alias文件路径配置ng ...

  6. nginx+tomcat实现动静态分离

    ===============Tomcat 概述: Tomcat是Apache 软件基金会(Apache Software Foundation)的Jakarta 项目中的一个核心项目,由Apache ...

  7. nginx与tomcat 组合 实现静态文件和jsp组合访问

    主要修改nginx的配置文件: 设置代理 location /{proxy_pass http://47.94.158.2:8080;proxy_redirect off;proxy_set_head ...

  8. Nginx+Tomcat构建动、静分离WEB架构

    一.简介 二.环境介绍 三.后端服务器安装配置 四.安装论坛 五.安装配置前端Nginx服务器 六.验证服务 一.Tomcat简介 Tomcat是Apache 软件基金会(Apache Softwar ...

  9. Linux下Nginx+Tomcat负载均衡和动静分离配置要点

    本文使用的Linux发行版:CentOS6.7 下载地址:https://wiki.centos.org/Download 一.安装Nginx 下载源:wget http://nginx.org/pa ...

随机推荐

  1. sublime work flow

    Tools -> Developer -> New Snippet <snippet> <content><![CDATA[ }() { ${} } ]]&g ...

  2. window系统下,简单的FTP上传和下载操作

    先假设有一FTP服务器,FTP服务器:qint.ithot.net,用户名:username   密码:user1234.在本地电脑D:盘创建一个文件夹"qint".将要上传的文件 ...

  3. 自定义组件-支持PNG图片的多态GraphicButton

    按钮功能使用TButton也可以解决, 但是TButton是会获得焦点的, 很多时候我们要求按钮不获得焦点, 而Speedbutton又不支持PNG图片 所以按照TSpeedbutton的代码, 重新 ...

  4. LoadRunner函数示例:lr_paramarr_random()

    lr_paramarr_random()函数的作用为:从一个参数数组中随机抽取一个值并以字符串形式返回.其使用方式及返回方式如下: char * lr_paramarr_random( const c ...

  5. Tomcat catalina.out日志使用log4j按天分割

    由于tomcat catalina.out日志不会自动分割, 一.日志分割所需包在附近中 1. 压缩包中有三个jar包: log4j-1.2.16.jar tomcat-juli-adapters.j ...

  6. node静态资源管理变迁之路

    使用express自带的,express.static,如:app.use(express.static('hehe')),就可以用localhost/hua.png,访问项目根目录下,hehe文件夹 ...

  7. ROW_NUMBER() OVER() 用法

    语法 ROW_NUMBER ( ) OVER ( [ PARTITION BY value_expression , ... [ n ] ] order_by_clause ) 参数 PARTITIO ...

  8. php代码性能分析方法

    1.用到的函数 microtime() ,函数返回当前 Unix 时间戳和微秒数,本函数以 "msec sec" 的格式返回一个字符串,其中 sec 是自 Unix 纪元(0:00 ...

  9. 命名空间“System.Web”中不存在类型或命名空间名称“Optimization”(是否缺少程序集引用?)

    今天,在.net4.5,mvc4下新建了个区域,运行起来就报这个错误: 命名空间"System.Web"中不存在类型或命名空间名称"Optimization"( ...

  10. Python之路【第十九章】:Django进阶

    Django路由规则 1.基于正则的URL 在templates目录下创建index.html.detail.html文件 <!DOCTYPE html> <html lang=&q ...