标签:ret cache cat size nginx shel methods origin control
同域部署
。后端
项目做反向代理,做还有额外配置:location / {
# 1.针对复杂请求,的前导OPTIONS请求,采取一律放行政策,Nginx拦截后直接返回200,不打到后端接口,避免后端认证等问题(因为OPTIONS请求不支持自定义头)
if ($request_method = ‘OPTIONS‘) {
return 200;
}
# 2.文件上传大小限制
client_max_body_size 3g;
# 3.给所有请求添加响应头,主要是允许跨域
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 ‘origin,Authorization,Cache-Control,Content-Type‘;
# 4.后端反向代理
proxy_pass http://192.168.50.87:8090;
}
标签:ret cache cat size nginx shel methods origin control
原文地址:https://www.cnblogs.com/JaxYoun/p/13092333.html