奇忠诚 发表于 2017-12-23 07:52:20

nginx作为下载文件服务器

#usernobody;  
worker_processes1;
  

  
#error_loglogs/error.log;
  
#error_loglogs/error.lognotice;
  
#error_loglogs/error.loginfo;
  

  
#pid      logs/nginx.pid;
  

  

  
events {
  worker_connections1024;
  
}
  

  

  
http {
  include       mime.types;
  default_typeapplication/octet-stream;
  

  #log_formatmain'$remote_addr - $remote_user [$time_local] "$request" '
  #                  '$status $body_bytes_sent "$http_referer" '
  #                  '"$http_user_agent" "$http_x_forwarded_for"';
  

  #access_loglogs/access.logmain;
  

  sendfile      on;
  #tcp_nopush   on;
  

  #keepalive_timeout0;
  keepalive_timeout65;
  

  #gzipon;
  

  server {
  listen       8080;
  server_namelocalhost;
  

  #charset koi8-r;
  

  #access_loglogs/host.access.logmain;
  

  location / {
  #root   html;
  #indexindex.html index.htm;
  

  if ($request_filename ~* ^.*?\.(txt|doc|pdf|rar|gz|zip|docx|exe|xlsx|ppt|pptx)$){
  add_header Content-Disposition: 'attachment;';
  }
  }
  #error_page404            /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;
  }
  }
  
}
  
页: [1]
查看完整版本: nginx作为下载文件服务器