The situation is like this:
1# The domain name resolver resolves to Baidu Cloud Accelerator, and then resolves from Baidu Cloud Accelerator to the origin IP, 103.25.199.246; after that, the client opens completely normally, as shown in the middle frame as shown below it shows good.
2# The following is the reverse generation acceleration achieved by using Nginx,
The origin site is: mkt.guticn.com
The origin site IP is: 103.25.199.246
The proxy domain name is: mkt.guticn.com
The proxy IP is: the public IP of your own proxy
The nginx configuration on the proxy is
server {
server_name mkt.guticn.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.guticn.com
proxy_pass http://mkt.guticn.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';
}
proxy_redirect ~http(.)guticn.com(. ) http$guticn.com$2;
proxy_cookie_domain guticn.com guticn.com;
}
}
Open http://mkt.guticn.com/onebook..., 400 appears, as shown in the figure below,
## Can’t be displayed. It’s very strange. I can’t find it no matter how I check it. I’ve also grabbed the package and it’s no problem. It just shows 400. It’s annoying. Little sister, I’m going crazy. I’ve been doing this for several months. , the boss always urges me.
0x2# I also tried Accelerate, and then a 400 error also appeared.
0x3# I felt like it , must it be configured incorrectly?
Friends who have seen it, you can try it. Test method:
1. Open a virtual machine and install the above configuration.
2. Change the HOST of your physical machine to a virtual machine. , you can test it by accessing it. Thank you everyone.
Girl.
Since it is a 400 error and it is still a problem that must occur, then locate it step by step. Solving the problem cannot be a elimination method. I can only give you some advice.
Determine the end point of the request (that is, where the problem occurs) nginx can view it through access.log
Simplify the configuration to ensure that functions can run normally under the most basic configuration and avoid unnecessary interference
The source site is: mkt.guticn.com
The proxy domain name is: mkt.guticn.com Are your two domain names the same? Client access
mkt.guticn.com
地址,nginx又转发到mkt.guticn.com
address, what does this configuration mean?1. There is no log returned. What is returned is the POST 400 one, which is a useful log, and the others are normal logs.
2. The simplest reverse proxy that has been tested has no results.
It’s like CDN acceleration.