To increase PHP execution timeout, increase in php.ini. To see where your php.ini is located, see phpinfo().
max_execution_time = 60 #this is in seconds
To increase nginx's timeout on reading from backend, increase in nginx config (nginx/nginx.conf).
This is an assumption, but since you say you are making a POST request, increase cURL timeout
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,0);
curl_setopt($ch, CURLOPT_TIMEOUT, 400); //timeout in seconds
Be sure to set timeouts with precedence in mind. PHP will keep processing even if nginx decided to stop listening. etc.