nginx文件服务器文件日期,nginx文件目录服务器

用nginx配置一个文件服务器,并解决中文乱码问题,配置文件

server {

listen 80;

server_name downloadapp.3vyd.com;

location / {

add_header 'Access-Control-Allow-Origin' '*' always;

add_header 'Access-Control-Allow-Credentials' 'true';

add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';

add_header 'Access-Control-Allow-Headers' 'Range';

root /var/packages;

autoindex on;

autoindex_localtime on;

autoindex_exact_size off;

charset utf-8;

try_files $uri $uri/ /index.html;

}

}

96560e2f4e47

image.png

如果,开放目录,当时不允许直接访问,只能访问指定路径下的html文件,nginx.conf的配置如下

pid /var/run/nginx.pid;

events {

worker_connections 1024;

}

http {

include /etc/nginx/mime.types;

default_type application/octet-stream;

add_header Access-Control-Allow-Origin *;

add_header Access-Control-Allow-Headers *;

add_header Access-Control-Allow-Credentials true always;

add_header Access-Control-Allow-Methods GET,POST,OPTIONS;

add_header Access-Control-Max-Age 1728000 always;

server {

listen 8088;

server_name localhost;

# location / {

# root /var/jenkins/report/admin/dist;

# try_files $uri $uri/ /index.html;

# index index.html;

# }

location /report {

if ($request_method = 'OPTIONS') {

add_header 'Access-Control-Allow-Origin' '*';

add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS';

add_header 'Access-Control-Allow-Headers' '*';

return 204;

}

root /var/jenkins_home;

try_files $uri $uri/ /index.html;

index index.html;

}

location ~* \.(eot|ttf|woff)$ {

add_header Access-Control-Allow-Origin *;

}

}

96560e2f4e47

image.png

96560e2f4e47

403

参考

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值