我正在使用 nginx (1.9.3) + php-fpm(通过 unix 套接字)和另一个 nginx 作为反向代理。在从一个子域到另一个子域(cloud.example.com 到 api.example.com)的 XHR 请求net::ERR_INCOMPLETE_CHUNKED_ENCODING
期间,我很少收到(大约 100 个请求中的 1个)。OPTIONS
此 OPTIONS 请求在 POST 之前自动发送。Chrome 版本 50.0.2661.94(64 位)OS X
反向代理:
location / {
proxy_pass http://xxx.xxx.xxx.xxx:80;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
proxy_buffering off;
}
请求标头:
OPTIONS /my/request/uri HTTP/1.1
Host: api.example.com
Connection: keep-alive
Access-Control-Request-Method: POST
Origin: https://subdomain.example.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36
Access-Control-Request-Headers: accept, content-type
Accept: */*
Referer: https://subdomain.example.com/
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8,ru;q=0.6
响应标头:
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 13 May 2016 06:39:05 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
Access-Control-Allow-Origin: https://subdomain.example.com
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Content-Type
Content-Encoding: gzip
Strict-Transport-Security: max-age=31536000; includeSubdomains;
我的猜测是这可能是由超时引起的,但我怀疑某处是否存在毫秒超时。下面的屏幕截图来自一个 Chrome 开发者工具网络选项卡,该选项卡被重复多次的相同请求过滤。
任何帮助深表感谢!