nginx搭建文件服务器

nginx 配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
server {
listen 443;
# 对应的域名,多个以空格分开
server_name cdn.xxx.com;
charset utf-8;

# 证书文件地址
#ssl_certificate /data/ssl/cdn.xxx.com_bundle.crt;
ssl_certificate /data/ssl/cdn.xxx.com.pem;
# 证书key
ssl_certificate_key /data/ssl/cdn.xxx.com.key;

#监听/file的路由地址映射到磁盘
location /file {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Credentials true;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
add_header Access-Control-Allow-Headers DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type;
alias /data/file;
}
}