nginx 下载文件

第一种:通过url 下载

1.修改nginx 配置

location /downloads/ {

alias /usr/file/;

autoindex on;

add_header Content-Disposition 'attachment; filename="$uri"';

sendfile on;

}

 2.重启nginx 

./nginx -s reload

3. 在 usr/file 文件夹下 新建文件   11.java

http://192.168.11.195/downloads/11.java

 

第二种:通过浏览器下载,vi 进入编辑,i 编辑 , :wq 退出

location / {

root /usr/file;

autoindex on;

index index.html index.htm;

}

 

 

 2.重启nginx 

./nginx -s reload

通过ID 直接访问

 

posted @ 2025-03-05 17:08  黑狗已醒  阅读(159)  评论(0)    收藏  举报