使用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 核心,很多的常用的第三方模块,以及它们的大多数依赖项. 通过众多 ...
随机推荐
- 2. redis的数据类型
一. string类型 字符串类型是redis中最基本的数据类型,它能存储任何形式的内容,包含二进制数据,甚至是一张图片(二进制内容).一个字符串类型的值存储的最大容量是1GB 命令 (1)setnx ...
- SOA_环境安装系列3_Oracle Weblogic安装和环境搭建(案例)
2014-01-03 Created By BaoXinjian
- NeHe OpenGL教程 第七课:光照和键盘
转自[翻译]NeHe OpenGL 教程 前言 声明,此 NeHe OpenGL教程系列文章由51博客yarin翻译(2010-08-19),本博客为转载并稍加整理与修改.对NeHe的OpenGL管线 ...
- 转-android图片降低图片大小保持图片清晰的方法
http://i.cnblogs.com/EditPosts.aspx?opt=1 android里面对于图片的处理一直是个比较烦人的问题,烦人之处在于一个不小心,就有可能造成OOM. 最近碰到一个关 ...
- 树莓派用USB蓝牙适配器连接蓝牙设备
下面分享如何配置蓝牙设备.1.连接蓝牙适配到Rpi板子usb上,安装相关蓝牙服务器和驱动 lsusb 查看设备是不是被发现 pi @RaspberryPi ~ $ lsusb Bus 001 Devi ...
- SVN---脱离SVN控制
创建一个记事本文件,然后吧这句话复制进去for /r . %%a in (.) do @if exist "%%a\.svn" rd /s /q "%%a\.svn&qu ...
- C++学习14 继承的概念及语法
继承是类与类之间的关系,是一个很简单很直观的概念,与现实世界中的继承(例如儿子继承父亲财产)类似. 继承(Inheritance)可以理解为一个类从另一个类获取成员变量和成员函数的过程.例如类B继承于 ...
- HTML5的动画学习历程
一.三角学原理. function getRadio(d){//根据角度获得弧度, return d*Math.PI/180; }, fun ...
- django 模板if判断的时候==两边需要有空格
比如 {%if a=='y'%}错误,{%if a =='y'%}也是错误的 只能是{%if a == 'y'%}这样才行
- CodeForces 604D 【离散数学 置换群】
题意: 给你一个方程,方程太变态不打,给你一个p一个k,p保证是大于等于3的质数,k保证在0~p-1之间的整数.要求对应函数的定义域在0~p-1值域为0~p-1的子集,求这样的函数有多少个... 分析 ...