nginx 跨越配置处理


server {

listen 80; # 监听的端口号
server_name localhost; # 服务器名称
client_max_body_size 100m; # 定义读取客户端请求头的超时时间

location / {
root "D:/phpstudy_pro/WWW/local.sbc.com/web"; # 静态资源目录
index index.html index.htm;

#add_header 'Access-Control-Allow-Origin' 'https://10.10.99.112:9684';


location ~ \.(json)$ {
add_header 'Access-Control-Allow-Origin' 'http://10.10.99.112:9684';

add_header Access-Control-Max-Age 1728000;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
add_header Content-Type' 'text/plain; charset=utf-8';
#add_header Content-Length 0;



#rewrite ^(.*) http://10.10.99.112:9684$1 redirect;
rewrite ^(.*) /$1 break;
proxy_pass http://10.10.99.112:9684$1;


}


#if ($args ~ json){
# rewrite ^ http://10.10.99.112:9684/ permanent;
#}


}}

posted @ 2021-12-28 16:16  北京小小鸟  阅读(122)  评论(0)    收藏  举报