nginx+tomcat+二级域名静态文件分离支持mp4视频播放配置实例
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视频播放配置实例的更多相关文章
- Nginx +Tomcat 实现动静态分离(转)
Nginx +Tomcat 实现动静态分离 动静态分离就是Nginx处理客户端的请求的静态页面(html页面)或者图片,Tomcat处理客户端请求的动态页面(jsp页面),因为Nginx处理的静态页面 ...
- Nginx+Tomcat负载均衡、动静分离群集
Nginx+Tomcat负载均衡.动静分离群集 目录 Nginx+Tomcat负载均衡.动静分离群集 一.Tomcat 1. Tomcat简介 2. Tomcat重要目录 二.Nginx负载均衡原理 ...
- nginx + tomcat 单个域名及多个域名的配置
//nginx + tomcat 单个域名及多个域名的配置//修改nginx的配置文件,linux默认路径 /usr/local/nginx/conf/nginx.conf //prot为8082的w ...
- NGINX不允许向静态文件提交POST方式的请求,否则报405错误(apache中没有出现)
telnet *.*.*.* 80POST /map/navigation/2011winter/jsn/jsn_20120723_pack/pvf.jsnHTTP/1.1Host:*.*.*.* ( ...
- Nginx中的root&alias文件路径及索引目录配置详解
这篇文章主要介绍了Nginx中的root&alias文件路径及索引目录配置,顺带讲解了root和alias命令的用法,需要的朋友可以参考下 root&alias文件路径配置ng ...
- nginx+tomcat实现动静态分离
===============Tomcat 概述: Tomcat是Apache 软件基金会(Apache Software Foundation)的Jakarta 项目中的一个核心项目,由Apache ...
- nginx与tomcat 组合 实现静态文件和jsp组合访问
主要修改nginx的配置文件: 设置代理 location /{proxy_pass http://47.94.158.2:8080;proxy_redirect off;proxy_set_head ...
- Nginx+Tomcat构建动、静分离WEB架构
一.简介 二.环境介绍 三.后端服务器安装配置 四.安装论坛 五.安装配置前端Nginx服务器 六.验证服务 一.Tomcat简介 Tomcat是Apache 软件基金会(Apache Softwar ...
- Linux下Nginx+Tomcat负载均衡和动静分离配置要点
本文使用的Linux发行版:CentOS6.7 下载地址:https://wiki.centos.org/Download 一.安装Nginx 下载源:wget http://nginx.org/pa ...
随机推荐
- js 获取指定日期
查询几天后的js代码,如果查询当天的日期 if($("input[name='startTime']").val()==""){ $("input[n ...
- linux的sysctl基本配置
# Controls the use of TCP syncookiesnet.ipv4.tcp_syncookies = 1 # me write paramnet.ipv4.tcp_timesta ...
- MYSQL 多行转多列
mysql 行变列(多行变成一行/多行合并成一行/多行合并成多列/合并行),我觉得这都是一个意思 数据库结构如图: 而我想让同一个人的不同成绩变成此人在这一行不同列上显示出来,此时分为2中展现: 第一 ...
- Spring mvc example
Spring mvc example 1.下载spring源包 spring地址:http://www.springsource.org/download 我下的是spring-framework-3 ...
- pdb调试技巧
1.先import pdb 在适当的位置加上pdb.set_trace(),在cmd中运行脚本,就可以看到调试的提示符 2.常用的调试命令 h(elp),会打印当前版本,pdb可用的命令,如果要查询某 ...
- RunLoop相关知识的总结
RunLoop 即运行循环,也叫事件循环,本质为一个死循环.iOS一个程序运行起来之后,默认会开启一个运行循环,有需要处理的操作时,比如用户的输入事件时,RunLoop会自己跑起来运行,没有需要处理的 ...
- 关于smarty的一些个人笔记
注释为{注释} 注意下面代码中<%extends file="路径"%>和<%widget name="路径"%>这两个路径中的区别 c ...
- 在Update表数据同时将数据备份
分享一条有意思的SQL语句,也是前两天有个朋友在面试的时候碰到的,他当时没有做出来,回来之后问我, 如何在同一条语句中实现,更新表的时候同时备份更新前的记录数据. --在修改数据前,先要把修改前的数据 ...
- dsview
http://blog.csdn.net/gzshun/article/details/7495488 http://blog.csdn.net/hjl_1991/article/details/50 ...
- 手机QQ内置网页,微信内置网页中进行分享到QQ和微信的操作
微信内的网页分享: API内容详见微信开发文档 https://mp.weixin.qq.com/wiki 这里需要注意的是:调用微信API的时候修改的是微信内网页右上角三个点那里打开后,选择分享之 ...