1,主配置文件nginx.xml

  1. #user nobody;
  2. worker_processes 1;
  3.  
  4. #error_log logs/error.log;
  5. #error_log logs/error.log notice;
  6. #error_log logs/error.log info;
  7.  
  8. #pid logs/nginx.pid;
  9.  
  10. events {
  11. worker_connections 1024;
  12. }
  13.  
  14. http {
  15. include mime.types;
  16. default_type application/octet-stream;
  17.  
  18. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  19. # '$status $body_bytes_sent "$http_referer" '
  20. # '"$http_user_agent" "$http_x_forwarded_for"';
  21.  
  22. #access_log logs/access.log main;
  23.  
  24. sendfile on;
  25. #tcp_nopush on;
  26.  
  27. #keepalive_timeout 0;
  28. keepalive_timeout 65;
  29.  
  30. #gzip on;
  31.  
  32. include sites-enabled/yixin.conf;
  33. # include sites-enabled/diandian.conf;
  34. include sites-enabled/bestpay-weixinpub.conf;
  35. include sites-enabled/ccfa.conf;
  36. server {
  37. listen 80;
  38. server_name www.deeblue.org;
  39.  
  40. #charset koi8-r;
  41.  
  42. #access_log logs/host.access.log main;
  43.  
  44. location / {
  45. root html;
  46. index index.html index.htm;
  47. }
  48.  
  49. #error_page 404 /404.html;
  50.  
  51. # redirect server error pages to the static page /50x.html
  52. #
  53. error_page 500 502 503 504 /50x.html;
  54. location = /50x.html {
  55. root html;
  56. }
  57.  
  58. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  59. #
  60. #location ~ \.php$ {
  61. # proxy_pass http://127.0.0.1;
  62. #}
  63. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  64. #
  65. #location ~ \.php$ {
  66. # root html;
  67. # fastcgi_pass 127.0.0.1:9000;
  68. # fastcgi_index index.php;
  69. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
  70. # include fastcgi_params;
  71. #}
  72.  
  73. # deny access to .htaccess files, if Apache's document root
  74. # concurs with nginx's one
  75. #
  76. #location ~ /\.ht {
  77. # deny all;
  78. #}
  79. }
  80.  
  81. # another virtual host using mix of IP-, name-, and port-based configuration
  82. #
  83. #server {
  84. # listen 8000;
  85. # listen somename:8080;
  86. # server_name somename alias another.alias;
  87.  
  88. # location / {
  89. # root html;
  90. # index index.html index.htm;
  91. # }
  92. #}
  93.  
  94. # HTTPS server
  95. #
  96. #server {
  97. # listen 443 ssl;
  98. # server_name localhost;
  99.  
  100. # ssl_certificate cert.pem;
  101. # ssl_certificate_key cert.key;
  102.  
  103. # ssl_session_cache shared:SSL:1m;
  104. # ssl_session_timeout 5m;
  105.  
  106. # ssl_ciphers HIGH:!aNULL:!MD5;
  107. # ssl_prefer_server_ciphers on;
  108.  
  109. # location / {
  110. # root html;
  111. # index index.html index.htm;
  112. # }
  113. #}
  114.  
  115. }

2,sites-enabled/ccfa.conf

  1. upstream ccfa_server {
  2. server localhost:8080;
  3. ip_hash;
  4. }
  5.  
  6. server {
  7. listen 80;
  8. server_name diandian.deeblue.org;
  9. # individual nginx logs for this web vhost
  10. access_log /usr/local/nginx/logs/misc/access.log;
  11. error_log /usr/local/nginx/logs/misc/error.log ;
  12. location = /favicon.ico {
  13. return 404;
  14. }
  15.  
  16. #when not specify request uri, redirect to /index;
  17. location = / {
  18. rewrite ^ /ccfa/index.jsp ;
  19. }
  20.  
  21. #static files
  22. location ~ ^/(assets|templates|js|img|css|public|easyui-1.3.5)/(.*)$ {
  23. #root /usr/local/jetty/webapps/ccfa/;
  24. root /usr/local/eddy/static/;
  25. expires -1s;
  26. access_log off;
  27. }
  28. #location ~ ^/(download)/(.*)$ {
  29. # root /usr/local/jetty/webapps/ccfa/;
  30. #root /usr/local/eddy/static/;
  31. # expires -1s;
  32. # access_log off;
  33. #}
  34.  
  35. #location /submit/ {
  36. # charset utf-8;
  37. # alias /usr/local/eddy/static/download/; #文件的根目录(允许使用本地磁盘,NFS,NAS,NBD等)
  38. # internal;
  39. #}
  40.  
  41. #location /course/ {
  42. # charset utf-8;
  43. # alias /usr/local/eddy/static/; #文件的根目录(允许使用本地磁盘,NFS,NAS,NBD等)
  44. # internal;
  45. # }
  46. location ~ ^/download/(.*)$ {
  47. charset utf-8;
  48. add_header Content-Disposition "attachment; filename=$1";
  49. alias "/usr/local/eddy/static/download/$1";
  50. }
  51.  
  52. location / {
  53. proxy_pass http://ccfa_server;
  54. proxy_set_header X-Real-IP $remote_addr;
  55. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  56. proxy_set_header Host $http_host;
  57. proxy_redirect off;
  58. client_max_body_size 10m;
  59. client_body_buffer_size 128k;
  60.  
  61. proxy_connect_timeout 90;
  62. proxy_send_timeout 90;
  63. proxy_read_timeout 90;
  64.  
  65. proxy_buffer_size 4k;
  66. proxy_buffers 4 32k;
  67. proxy_busy_buffers_size 64k;
  68. proxy_temp_file_write_size 64k;
  69. }
  70.  
  71. }

⚠:此处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. 2. redis的数据类型

    一. string类型 字符串类型是redis中最基本的数据类型,它能存储任何形式的内容,包含二进制数据,甚至是一张图片(二进制内容).一个字符串类型的值存储的最大容量是1GB 命令 (1)setnx ...

  2. SOA_环境安装系列3_Oracle Weblogic安装和环境搭建(案例)

    2014-01-03 Created By BaoXinjian

  3. NeHe OpenGL教程 第七课:光照和键盘

    转自[翻译]NeHe OpenGL 教程 前言 声明,此 NeHe OpenGL教程系列文章由51博客yarin翻译(2010-08-19),本博客为转载并稍加整理与修改.对NeHe的OpenGL管线 ...

  4. 转-android图片降低图片大小保持图片清晰的方法

    http://i.cnblogs.com/EditPosts.aspx?opt=1 android里面对于图片的处理一直是个比较烦人的问题,烦人之处在于一个不小心,就有可能造成OOM. 最近碰到一个关 ...

  5. 树莓派用USB蓝牙适配器连接蓝牙设备

    下面分享如何配置蓝牙设备.1.连接蓝牙适配到Rpi板子usb上,安装相关蓝牙服务器和驱动 lsusb 查看设备是不是被发现 pi @RaspberryPi ~ $ lsusb Bus 001 Devi ...

  6. SVN---脱离SVN控制

    创建一个记事本文件,然后吧这句话复制进去for /r . %%a in (.) do @if exist "%%a\.svn" rd /s /q "%%a\.svn&qu ...

  7. C++学习14 继承的概念及语法

    继承是类与类之间的关系,是一个很简单很直观的概念,与现实世界中的继承(例如儿子继承父亲财产)类似. 继承(Inheritance)可以理解为一个类从另一个类获取成员变量和成员函数的过程.例如类B继承于 ...

  8. HTML5的动画学习历程

    一.三角学原理. function getRadio(d){//根据角度获得弧度,                return d*Math.PI/180;                }, fun ...

  9. django 模板if判断的时候==两边需要有空格

    比如 {%if a=='y'%}错误,{%if a =='y'%}也是错误的 只能是{%if a == 'y'%}这样才行

  10. CodeForces 604D 【离散数学 置换群】

    题意: 给你一个方程,方程太变态不打,给你一个p一个k,p保证是大于等于3的质数,k保证在0~p-1之间的整数.要求对应函数的定义域在0~p-1值域为0~p-1的子集,求这样的函数有多少个... 分析 ...