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