Snapshot restore is getting 504 gateway timeout

When I try to restore, after running for 5 mins it's showing 5-4 gateway error. I have also enabled debug log, but the file is not generated.

I have increased execution time and input time to 300 as well as the following defines:
define('SNAPSHOT_TABLESET_CHUNK_SIZE', 200);
define('SNAPSHOT_FILESET_CHUNK_SIZE', 50);

But no help!