1.媒介 當我們但愿分享本身的文件時,有多種方法,局域網可以回收共享,rtx傳輸,qq傳輸,發送到郵箱,直接u盤拷貝等等。但最簡樸的就是開啟當地處事器,其他電腦通過網頁的方法直接下載,這里先容利用nginx作為處事器舉辦下載
2.步調
1.下載nginx http://nginx.org/en/download.html 今朝不變版本為1.80 解壓到一個目次
2.修改設置文件 nginx.conf
#user nobody;
worker_processes ;
#error_log logs/ "hljs-keyword">error.log;
#error_log logs/ "hljs-keyword">error.log notice;
#error_log logs/ "hljs-keyword">error.log info;
#pid logs/nginx.pid;
events {
worker_connections ;
}
http {
include mime.types;
default_type application/octet-stream;
"hljs-preprocessor">#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
"hljs-preprocessor"># '$status $body_bytes_sent "$http_referer" '
"hljs-preprocessor"># '"$http_user_agent" "$http_x_forwarded_for"';
"hljs-preprocessor">#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout ;
#gzip on;
server {
listen ;
server_name localhost;
#charset koi8-r;
"hljs-preprocessor">#access_log logs/host.access.log main;
location / {
#root html;
"hljs-preprocessor">#index index.html index.htm;
"hljs-keyword">if ($request_filename ~* ^.*?.(txt|doc|pdf|rar|gz|zip|docx|exe|xlsx|ppt|pptx)$){
add_header Content-Disposition: "hljs-string">'attachment;';
}
}
"hljs-preprocessor">#error_page 404 /404.html;
"hljs-preprocessor"># redirect server "hljs-keyword">error pages to the static page /50x.html
#
error_page /x.html;
location = /x.html {
root html;
}
}
}
3.在nginx目次下的html中成立目次test和test.rar文件
4.打開呼吁行切換到nginx目次
4.1測試劇本 nginx -t
4.2開啟處事器 start nginx
4.3打開欣賞器 http://localhost:8080/test/test.rar應該彈出另存為對話框
4.4封鎖處事器nginx -s quit
,新加坡電信服務器 馬來西亞服務器