使用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 核心,很多的常用的第三方模块,以及它们的大多数依赖项. 通过众多 ...
随机推荐
- Android四:sqllite
1.扩展类SQLiteOpenHelper xxSQLiteHelper extends SQLiteOpenHelper public xxSQLiteHelper(Context context, ...
- maven命令行跳过test
mvn跳过测试的两种方法: -DskipTests -Dmaven.test.skip=true
- ylbtech-Unitity-cs:计算阶乘值
ylbtech-Unitity-cs:计算阶乘值 1.A,效果图返回顶部 1.B,源代码返回顶部 1.B.1, using System; namespace Functions { public ...
- 关于Switch结构利用
三大流程结构,循环.分支.if ,循环与条件选择结构用的比较多,而swicth用的比较少,swicth可以用if代替,只不过麻烦,最终都能实现输入和输出的条件对应 Swicth利用 ...
- JAVA 网格布局管理器
//网格布局管理器 import java.awt.*; import javax.swing.*; public class Jiemian3 extends JFrame{ //定义组件 JBut ...
- Java多线程之简单的线程同步实例
数据类: package Thread.MyCommon; public class Data { public int num = 0; public synchronized int getEve ...
- php 防止sql注入
Q:如果把用户输入的没有任何改动的放到SQL的查询语句中,很有可能会导致SQL注入,比如说下面的例子: $unsafe_variable = $_POST['user_input']; mysql_q ...
- 【转】oracle数据库中varchar2陷阱
源地址:http://www.cnblogs.com/iyangyuan/p/3491215.html oracle数据库相信大家都比较熟悉,数据库中有一种非常常用的数据类型:字符串型. 对应该类型, ...
- 看oracle版本
源地址:http://www.cnblogs.com/wolfplan/p/3876164.html select * from v$version;
- list,set,map,数组之间的相互转换详细解析
1.list转setSet set = new HashSet(new ArrayList()); 2.set转listList list = new ArrayList(new HashSet()) ...