下面是我的配置,
server {
server_name
mkt.xpj000.com;
listen 80;
location / {
proxy_buffering 'off';
proxy_ignore_headers 'X-Accel-Buffering';
proxy_hide_header 'Access-Control-Allow-Origin';
proxy_hide_header 'Cache-Control';
proxy_set_header Host
mkt.yuan.com proxy_pass
http://mkt.yuan.com;
proxy_set_header X-Real-IP '$remote_addr';
proxy_set_header X-Forwarded-For '$proxy_add_x_forwarded_for';
proxy_hide_header 'content-security-policy';
proxy_set_header Accept-Encoding '';
proxy_ignore_client_abort 'on';
proxy_set_header Accept-Language 'zh-CN';
proxy_set_header Connection 'upgrade';
if ($request_method = 'OPTIONS') {
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,Accept';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'POST') {
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,Accept';
}
if ($request_method = 'GET') {
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,Accept';
}
subs_filter '
yuan.com' '
xpj000.com';
proxy_redirect ~http(.*)
yuan.com(.*) http$
xpj000.com$2;
proxy_cookie_domain
yuan.com xpj000.com;
proxy_cookie_domain ~(.*)\.yuan.com $
1.xpj000.com;
}
}
请大神们帮帮忙,谢谢了。