Solution
Simply increase the timeout; in my case I had to add the following lines to nginx.conf
file:
fastcgi_send_timeout 120s;
fastcgi_read_timeout 120s;
In my specific case, though, I am behind a reverse proxy. In other scenario, you may need to increase also the following (always assuming nginx):
proxy_connect_timeout 120s;
proxy_send_timeout 120s;
proxy_read_timeout 120s;