Maison >développement back-end >tutoriel php >nginx作为下载文件服务器
1.前言
2.步骤
<code><span>#user nobody;</span> worker_processes <span>1</span>; <span>#error_log logs/<span>error</span>.log;</span><span>#error_log logs/<span>error</span>.log notice;</span><span>#error_log logs/<span>error</span>.log info;</span><span>#pid logs/nginx.pid;</span>events { worker_connections <span>1024</span>; } http { include mime.types; default_type application/octet-stream; <span>#log_format main '$remote_addr - $remote_user [$time_local] "$request" '</span><span># '$status $body_bytes_sent "$http_referer" '</span><span># '"$http_user_agent" "$http_x_forwarded_for"';</span><span>#access_log logs/access.log main;</span> sendfile on; <span>#tcp_nopush on;</span><span>#keepalive_timeout 0;</span> keepalive_timeout <span>65</span>; <span>#gzip on;</span> server { listen <span>8080</span>; server_name localhost; <span>#charset koi8-r;</span><span>#access_log logs/host.access.log main;</span> location / { <span>#root html;</span><span>#index index.html index.htm;</span><span>if</span> ($request_filename ~* ^.*?\.(txt|doc|pdf|rar|gz|zip|docx|exe|xlsx|ppt|pptx)$){ add_header Content-Disposition: <span>'attachment;'</span>; } } <span>#error_page 404 /404.html;</span><span># redirect server <span>error</span> pages to the static page /50x.html</span><span>#</span> error_page <span>500</span><span>502</span><span>503</span><span>504</span> /<span>50</span>x.html; location = /<span>50</span>x.html { root html; } } }</code>
版权声明:本文为博主原创文章,未经博主允许不得转载。
以上就介绍了nginx作为下载文件服务器,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。