Nginx as download file server

Source: Internet
Author: User

1. Preface when we want to share their files, there are many ways, LAN can be shared, RTX transmission, QQ transmission, sent to the mailbox, direct U-disk copy and so on. But the simplest is to open the local server, other computers directly through the Web page download, here is the use of Nginx as a server to download 2. Step 1. Download Nginx http://nginx.org/en/download.html The current stable version is 1.80 Unzip to a directory 2. Modify the configuration file nginx.conf
#user Nobody;Worker_processes1;#error_log logs/error. log;#error_log logs/error. log notice;#error_log logs/error. log info;#pid logs/nginx.pid;Events {Worker_connections1024x768;}    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 $;#gzip on;server {Listen8080; 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 - 502 503 504/ -x.html; Location =/ -x.html {root HTML; }    }}
3. Create directory Test and Test.rar file in HTML in Nginx directory 4. Open command line switch to nginx Directory 4.1 test script nginx-t4.2 Start server start nginx4.3 Open Browser http://localhost : 8080/test/test.rar should pop up Save As dialog box 4.4 shut down server Nginx-s quit

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Nginx as download file server

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.