Nginx as the file download server

Source: Internet
Author: User
: This article mainly introduces nginx as a file download server. if you are interested in PHP tutorials, refer to it. 1. Preface

When we want to share our own files, there are multiple ways to use sharing, rtx transmission, qq transmission, email sending, and direct USB flash drive copying. However, the simplest method is to enable the local server. other computers can directly download the server through web pages. here we will introduce how to use nginx as the server for download.

2. steps

1. download nginx http://nginx.org/en/download.html for current stable version 1.80 unzip to a directory 2. modify the configuration file nginx. conf
#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;    server {        listen       8080;        server_name  localhost;        #charset koi8-r;#access_log  logs/host.access.log  main;        location / {            #root   html;#index  index.html index.htm;if ($request_filename ~* ^.*?\.(txt|doc|pdf|rar|gz|zip|docx|exe|xlsx|ppt|pptx)$){            add_header Content-Disposition: 'attachment;';            }        }        #error_page  404              /404.html;# redirect server error pages to the static page /50x.html#        error_page   500502503504  /50x.html;        location = /50x.html {            root   html;        }    }}
3.create the directory testand test.rar files in HTML under the nginxdirectory. 4. open the command line to switch to the nginx directory 4.1 test script nginx-t4.2 enable server start nginx4.3 open the browser http: // localhost: 8080/test/test.rar should pop up the save as dialog box 4.4 close the server nginx-s quit

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

The above introduces nginx as a file downloading server, including some content. if you are interested in the PHP Tutorial, please help.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.