I have setup a nginx instance that proxies requests to our apigee instance. We need to do this because Apigee does not provide a way to make https requests directly to Apigee as it cannot verify our SSL certs.
Now, this nginx proxy works fine for most requests. But for requests with large responses, it intermittently fails. The nginx error
2015/01/30 11:37:46 [error] 10404#0: *3953 upstream prematurely closed connection while reading upstream, client: 172.31.40.204, server: apitest.zendrive.com, request: "GET /v1/driver/vishal-2@zendrive.com/trip/1422149911713?apikey=ANnyTq9U0Xu6cOorxwI3xkFEtWvohb7j&fields=info,score,events,simple_path,speed_profile HTTP/1.1", upstream: "https://107.23.127.90:443/v1/driver/vishal-2@zendrive.com/trip/1422149911713?apikey=ANnyTq9U0Xu6cOor...", host: "apitest.zendrive.com"
The nginx proxy config has
server {
listen 80;
server_name apitest.zendrive.com;
location / {
proxy_pass https://zendrive-prod.apigee.net;
error_log /var/log/nginx/apitest.log debug;
proxy_read_timeout 300s;
proxy_connect_timeout 300s;
proxy_buffer_size 4k;
proxy_buffers 256 4k;
proxy_temp_file_write_size 16k;
proxy_temp_path /mnt/data1/nginx/proxy_temp 1 2;
}
}
To reproduce this - the following request fails frequently.
$ curl -v "https://apitest.zendrive.com/v1/driver/vishal-2@zendrive.com/trip/1422149911713?apikey=ANnyTq9U0Xu6c..." -o /tmp/out
The nginx debug logs for this request does not indicate the cause.
2015/01/30 11:37:46 [debug] 10404#0: *3953 pipe write downstream done
2015/01/30 11:37:46 [debug] 10404#0: *3953 event timer: 36, old: 1422618166237, new: 1422618166395
2015/01/30 11:37:46 [debug] 10404#0: *3953 http upstream exit: 0000000000000000
2015/01/30 11:37:46 [error] 10404#0: *3953 upstream prematurely closed connection while reading upstream, client: 172.31.40.204, server: apitest.zendrive.com, request: "GET /v1/driver/vishal-2@zendrive.com/trip/1422149911713?apikey=ANnyTq9U0Xu6cOorxwI3xkFEtWvohb7j&fields=info,score,events,simple_path,speed_profile HTTP/1.1", upstream: "https://107.23.127.90:443/v1/driver/vishal-2@zendrive.com/trip/1422149911713?apikey=ANnyTq9U0Xu6cOor...", host: "apitest.zendrive.com"
2015/01/30 11:37:46 [debug] 10404#0: *3953 finalize http upstream request: 502
2015/01/30 11:37:46 [debug] 10404#0: *3953 finalize http proxy request
How can I resolve this?
I don't see any issue when downloading directly from zendrive-prod.apigee.net