一:安装Nginx 二:配置Nginx server { listen 80 default_server; server_name _; location / { root /usr/share/nginx/html/download; # 开启索引功能 autoindex on; # 显示本机时间而非 GMT 时间 autoindex_localtime on; # 关闭计算文件确切大小(单位bytes),只显示大概大小(单位kb、mb、gb) autoindex_exact_size off; } } 三:创建下载路径/usr/share/nginx/html/download mkdir /usr/share/nginx/html/download 四:上传文件并授权755 五:可以下载了,开心
Nginx 补充小知识:
Nginx反向代理,proxy_set_header Host xxxx; 各参数意义:
$server_port :nigix监听的端口 $proxy_port : 服务器真正访问的端口 $http_host : 是URL地址 =============== location ~ ^/(a|abc) { proxy_pass http://192.168.6.120:8080; # proxy_set_header Host $host:$server_port; # proxy_set_header Host $host:$proxy_port; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header User-Agent $http_user_agent; proxy_set_header Referer $http_referer; client_max_body_size 50m; client_body_buffer_size 256k; proxy_connect_timeout 300s; proxy_send_timeout 300s; proxy_read_timeout 300s; proxy_max_temp_file_size 128m; proxy_buffer_size 512k; proxy_buffers 16 512k; proxy_busy_buffers_size 512k; proxy_temp_file_write_size 512k; } access_log /tmp/photo_idcard.access.log access; }