nginx监听IP、配置前端、配置文件下载
upstream kyzs {
server 127.0.0.1:8000;
}
server {
listen 8360;
server_name "";
access_log /var/log/nginx/nginx-uwsgi.log;
charset utf-8;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
location / {
root /root/dist;
index index.html;
try_files $uri $uri/ /index.html;
}
location ~^/api {# 在这儿http://后面跟上前面的代号即可转发到kyzs的请求
proxy_pass http://kyzs;
}
location /download/ {
alias /root/files/;
if ($request_filename ~* ^.*?\.(html|doc|pdf|zip|docx|txt)$) {
add_header Content-Disposition attachment;
add_header Content-Type application/octet-stream;
}
sendfile on; # 开启高效文件传输模式
autoindex on; # 开启目录文件列表
autoindex_exact_size on; # 显示出文件的确切大小,单位是bytes
autoindex_localtime on; # 显示的文件时间为文件的服务器时间
charset utf-8,gbk; # 避免中文乱码
}
}