使用ngin的静态文件下载
1,主配置文件nginx.xml
#user nobody;
worker_processes 1; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
worker_connections 1024;
} http {
include mime.types;
default_type application/octet-stream; #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 logs/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout 0;
keepalive_timeout 65; #gzip on; include sites-enabled/yixin.conf;
# include sites-enabled/diandian.conf;
include sites-enabled/bestpay-weixinpub.conf;
include sites-enabled/ccfa.conf;
server {
listen 80;
server_name www.deeblue.org; #charset koi8-r; #access_log logs/host.access.log main; location / {
root html;
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;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} # another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} }
2,sites-enabled/ccfa.conf
upstream ccfa_server {
server localhost:8080;
ip_hash;
}
server {
listen 80;
server_name diandian.deeblue.org;
# individual nginx logs for this web vhost
access_log /usr/local/nginx/logs/misc/access.log;
error_log /usr/local/nginx/logs/misc/error.log ;
location = /favicon.ico {
return 404;
}
#when not specify request uri, redirect to /index;
location = / {
rewrite ^ /ccfa/index.jsp ;
}
#static files
location ~ ^/(assets|templates|js|img|css|public|easyui-1.3.5)/(.*)$ {
#root /usr/local/jetty/webapps/ccfa/;
root /usr/local/eddy/static/;
expires -1s;
access_log off;
}
#location ~ ^/(download)/(.*)$ {
# root /usr/local/jetty/webapps/ccfa/;
#root /usr/local/eddy/static/;
# expires -1s;
# access_log off;
#}
#location /submit/ {
# charset utf-8;
# alias /usr/local/eddy/static/download/; #文件的根目录(允许使用本地磁盘,NFS,NAS,NBD等)
# internal;
#}
#location /course/ {
# charset utf-8;
# alias /usr/local/eddy/static/; #文件的根目录(允许使用本地磁盘,NFS,NAS,NBD等)
# internal;
# }
location ~ ^/download/(.*)$ {
charset utf-8;
add_header Content-Disposition "attachment; filename=$1";
alias "/usr/local/eddy/static/download/$1";
}
location / {
proxy_pass http://ccfa_server;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
}
⚠:此处nginx代理的是localhost:8080
所以用户ngnix下载的url经过http://diandian.deeblue.org/download/chenli.pptx
其静态资源在/local/eddy/static
使用ngin的静态文件下载的更多相关文章
- flask+gunicorn中文文件下载报错问题及解决
导言 问题源起与一个静态文件下载的接口: from flask import Flask, current_app app = Flask(__name__) @app.route('/file_na ...
- 使用LayUI操作数据表格
接着 上一篇 继续完善我们的demo,这次我们加一个搜索按钮 搜索 在table标签的上方,加入这样一组html <div class="demoTable"> 搜索商 ...
- node.js上除了Express还有哪些好用的web开发框架
老司机都有体会, 开发本身没有多难, 最纠结其实是最初的技术和框架选型, 本没有绝对的好坏之分, 可一旦选择了不适合于自己业务场景的框架, 将来木已成舟后开发和维护成本都很高, 等发现不合适的时候更换 ...
- 23.app后端如何架设文件系统
现在app展现内容的形式多种多样的,有文字,图片,声音,视频等等,其中文件占了一个很大的比重.随着app不断运营,文件会越来越多,占用的磁盘空间也不断增大,架设一套高效的文件系统,对于整个app架构有 ...
- 实战http切换成https
Server端使用Nginx + Tomcat Niginx SSL on Tomcat SSL non 步骤: 1.修改代码,将外部引用的http js css 文件修改为https,若外部链接不支 ...
- PHP 利用nginx的X-sendfile控制下载,提高下载效率
https://blog.csdn.net/qq_34839657/article/details/52812885 https://www.jianshu.com/p/bf5c387830b7 为了 ...
- 一个NodeJS写的基于MVC的服务器
目前实现了静态文件下载.根据地址导航到控制器相应的控制器方法,但视图模版功能目前还未实现. 服务器代码(httpserver.js): var http = require("http&qu ...
- vue基础入门(4)
4.综合实例 4.1.基于数据驱动的选项卡 4.1.1.需求 需求说明: 1. 被选中的选项按钮颜色成橙色 2. 完成被选中选项下的数据列表渲染 3. 完成选项切换 4.1.2.代码实现 <!D ...
- OpenResty 作者章亦春访谈实录
[软件简介] OpenResty (也称为 ngx_openresty)是一个全功能的 Web 应用服务器.它打包了标准的 Nginx 核心,很多的常用的第三方模块,以及它们的大多数依赖项. 通过众多 ...
随机推荐
- 【MySQL】unique列插入重复值解决方案
当在一个UNIQUE键上插入包含重复值的记录时,我们可以控制MySQL如何处理这种情况:使用IGNORE关键字或者ON DUPLICATE KEY UPDATE子句跳过INSERT.中断操作或者更新旧 ...
- Spark1.4启动spark-shell时initializing失败
错误信息如下: 5/11/03 16:48:15 INFO spark.SparkContext: Running Spark version 1.4.1 15/11/03 16:48:15 WARN ...
- Shell_Oracle Erp和其他系统Interface资料传输通过Shell进行控制(案例)
2014-06-26 Created By BaoXinjian
- suibi1117
测试的重点是要检查数据的交换,传递和控制管理过程,以及系统间的相互逻辑依赖关系等. 我所了解的模块接口测试大体分为两类:模块接口测试和web接口测试 模块接口测试是单元测试的基础.它主要测试模块的调用 ...
- java虚拟机参数设置
-Xms8000M 初始化的堆大小 -Xmx8000M 堆的最大值 -XX:+HeapDumpOnOutOfMemoryError 堆溢出时Dump出当前内存堆转储快照以便事后分析 -XX:P ...
- Ubuntu设置环境变量并立即生效
Ubuntu Linux系统包含两类环境变量:系统环境变量和用户环境变量.系统环境变量对所有系统用户都有效,用户环境变量仅仅对当前的用户有效. 修改用户环境变量 用户环境变量通常被存储在下面的文件中: ...
- MySql中增加一列
如果想在一个已经建好的表中添加一列,可以用诸如: alter table TABLE_NAME add column NEW_COLUMN_NAME varchar(20) not null; 这条语 ...
- 编译 proto 文件到指定语言的代码
由于 Protocol Buffers 3 的正式版还没有发布,在官网(https://developers.google.com/protocol-buffers/docs/downloads)目前 ...
- EXT layout
1.Vbox createCenterPanel: function () { var pan = Ext.create('Ext.Panel', { height: '100%', title: ' ...
- [SQL] 要查询9 月份的数据中的任意时间段,可能是一个月的,也可能是1日到15日的
SELECT * FROM [表名] WHERE datediff(month,[列名],