#REWRITE-END
#允许跨域请求的域,* 代表所有
add_header 'Access-Control-Allow-Origin' *;
#允许请求的header
add_header 'Access-Control-Allow-Headers' *;
#允许带上cookie请求
add_header 'Access-Control-Allow-Credentials' 'true';
#允许请求的方法,比如 GET,POST,PUT,DELETE
add_header 'Access-Control-Allow-Methods' *;
#重定向
location /jj/{
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Headers' '*';
add_header 'Access-Control-Allow-Methods' '*';
if ($request_method = 'OPTIONS') {
return 204;
}
proxy_pass https://e.juejin.cn/;
# 针对200和304状态码缓存时间为8小时
proxy_cache_valid 200 304 1h;
}
Nginx 反向代理跨域
最新推荐文章于 2023-12-14 17:34:44 发布