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的静态文件下载的更多相关文章

  1. flask+gunicorn中文文件下载报错问题及解决

    导言 问题源起与一个静态文件下载的接口: from flask import Flask, current_app app = Flask(__name__) @app.route('/file_na ...

  2. 使用LayUI操作数据表格

    接着 上一篇 继续完善我们的demo,这次我们加一个搜索按钮 搜索 在table标签的上方,加入这样一组html <div class="demoTable"> 搜索商 ...

  3. node.js上除了Express还有哪些好用的web开发框架

    老司机都有体会, 开发本身没有多难, 最纠结其实是最初的技术和框架选型, 本没有绝对的好坏之分, 可一旦选择了不适合于自己业务场景的框架, 将来木已成舟后开发和维护成本都很高, 等发现不合适的时候更换 ...

  4. 23.app后端如何架设文件系统

    现在app展现内容的形式多种多样的,有文字,图片,声音,视频等等,其中文件占了一个很大的比重.随着app不断运营,文件会越来越多,占用的磁盘空间也不断增大,架设一套高效的文件系统,对于整个app架构有 ...

  5. 实战http切换成https

    Server端使用Nginx + Tomcat Niginx SSL on Tomcat SSL non 步骤: 1.修改代码,将外部引用的http js css 文件修改为https,若外部链接不支 ...

  6. PHP 利用nginx的X-sendfile控制下载,提高下载效率

    https://blog.csdn.net/qq_34839657/article/details/52812885 https://www.jianshu.com/p/bf5c387830b7 为了 ...

  7. 一个NodeJS写的基于MVC的服务器

    目前实现了静态文件下载.根据地址导航到控制器相应的控制器方法,但视图模版功能目前还未实现. 服务器代码(httpserver.js): var http = require("http&qu ...

  8. vue基础入门(4)

    4.综合实例 4.1.基于数据驱动的选项卡 4.1.1.需求 需求说明: 1. 被选中的选项按钮颜色成橙色 2. 完成被选中选项下的数据列表渲染 3. 完成选项切换 4.1.2.代码实现 <!D ...

  9. OpenResty 作者章亦春访谈实录

    [软件简介] OpenResty (也称为 ngx_openresty)是一个全功能的 Web 应用服务器.它打包了标准的 Nginx 核心,很多的常用的第三方模块,以及它们的大多数依赖项. 通过众多 ...

随机推荐

  1. RMQ问题ST算法 (还需要进一步完善)

    /* RMQ(Range Minimum/Maximum Query)问题: RMQ问题是求给定区间中的最值问题.当然,最简单的算法是O(n)的,但是对于查询次数很多(设置多大100万次),O(n)的 ...

  2. 黄聪:深入理解PHP Opcode缓存原理

    什么是opcode缓存? 当解释器完成对脚本代码的分析后,便将它们生成可以直接运行的中间代码,也称为操作码(Operate Code,opcode).Opcode cache的目地是避免重复编译,减少 ...

  3. 黄聪:如何使用WebKitBrowser调用元素点击事件(C#)

    string s = "var _elm = document.getElementById('loginBtn');var _evt = document.createEvent('Mou ...

  4. 在指定路径下查找并打印mdb类型文件

    1 #encoding:utf8 import os fpath = 'D:\Download\LP传奇-麒麟传说\Date' rfile = '' files = [] mdbFiles = [] ...

  5. SQL语言的三个分类:DDL、DML、DCL

    DML:数据操纵语言,主要是完成数据的新增,修改,删除和查询的操作. DDL:数据定义语言,主要是用来创建或修改表.视图.存储过程以及用户等. DCL:数据控制语言,是用来设置或更改数据库用户或角色权 ...

  6. hdu 5444 Elven Postman 二叉树

    Time Limit: 1500/1000 MS (Java/Others)   Memory Limit: 131072/131072 K (Java/Others) Problem Descrip ...

  7. ubuntu13.10下安装samba

    1.现在的ubuntu系统都默认安装了samba服务,如果是精简系统的话,可以通过apt-get进行安装 sudo apt-get install samba sudo apt-get cifs-ut ...

  8. 两款HTTP流量分析工具HttpWatch与Fiddler的比较(转)

    最近突然想看看HTTP的消息到底是怎么回事,在网上搜了几款软件来监控,并且搜到了下面的文章,感觉介绍的不错,就copy下来了.下文摘自:http://www.imkevinyang.com/2009/ ...

  9. [ActionScript 3.0] as3可以通过CDATA标签声明多行字符串

    var str:String=<![CDATA[YANSHUANGPING yanshuangping yanshuangping ]]>; trace(str); var myname: ...

  10. 日期选择控件-laydate

    laydate控件非常简单易用,只需要调用一个个函数就可以轻松实现日期时间选择. <%@ page language="java" import="java.uti ...