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. Android课程---如何用网格视图做出手机桌面APP

    activity_test.xml <?xml version="1.0" encoding="utf-8"?> <GridView xmln ...

  2. SharePoint Configuration Wizard - Unable to upgrade SharePoint Products and Technologies because an upgrade is already in progress

    故障描述 当要运行SharePonit Products and Technologies Configuration Wizard的时候,出现了如下图所示的错误提示. 错误信息为: Unable t ...

  3. Sprint会议记录(第五组)

    会议时间:12/8 下午14:00 会议地点:宿舍 会议进程: *首先我们讨论了实验第一个Sprint1要实现的功能:排球规则分析.比赛详细过程.比赛人物分析, *之后对是任务的认领, *最后每个人对 ...

  4. git 强制覆盖本地

    git fetch --all git reset --hard origin/master git pull 参考:https://ruby-china.org/topics/2494

  5. Java之内存诊断

    Java 内存诊断比较容易, 需要: 1 获取heap dump 2 分析heap dump 1.1 获取dump之1 VM arguments: -XX:+HeapDumpOnOutOfMemory ...

  6. jQuery jQuery对象与dom对象的转换

    jQuery对象本质上是一个构造函数,主要作用是返回jQuery对象的实例. jQuery选择器返回的是一个类似数组的对象,用下标运算取出的对象如$('body')[0],是dom对象,对此jquer ...

  7. iOS10新特性

    1.Siri API 的开放自然是 iOS 10 SDK 中最激动人心也是亮眼的特性.Apple 加入了一套全新的框架 Intents.framework 来表示 Siri 获取并解析的结果. 在 i ...

  8. 常用git命令纪录

    git branch xxx 新建分支xxx git branch -a 查看所有分支(包括远程) git remote add origin http://xxx.git  在本地添加一个远程仓库, ...

  9. ORA-03113: end-of-file on communication channel

    导致的原因,可能是异常断电导致文件状态不一致. SQL> startupORACLE instance started. Total System Global Area 1653518336 ...

  10. centos 安装redis并加入系统服务

    1.安装redis wget http://download.redis.io/releases/redis-3.2.5.tar.gz 解压:tar -zxvf redis-3.2.5.tar.gz ...