I found other threads discussing this but most had no answer and were locked. So figured I'd post my findings to help others, if you have settings that work for you please share.
Nginx server:
/etc/nginx/nginx.conf
Added to the http block (there are other settings here, these are the related settings to this issue)
http {
#This line added for moodle max size upload per https://docs.moodle.org/37/en/File_upload_size
client_max_body_size 2048m;
#Added to increase timeout to prevent 504 error
fastcgi_read_timeout 900;
fastcgi_send_timeout 900;
proxy_read_timeout 900;
send_timeout 900;
proxy_connect_timeout 900;
}On the Moodle Server behind the Nginx server
Edit /etc/php/7.2/apache2/php.ini
Add or update the following
max_execution_time = 900
max_input_time = 600
memory_limit = 128M
Also on the Moodle server for apache
/etc/apache2/apache2.conf
Update this:
Timeout 600
Hope this saves someone a few hours of time.