nginx -> thin で 504 Gateway Time-out
thin 側で時間が掛かる処理をする場合、往々にしてこうなります。
nginx 側のデフォルト設定は概ね60秒なので、proxy 関係の timeout 設定時間を変更して上げる必要があります。
send_timeout 300;
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
恐らく、proxy_send_timeout は要らないと思われます。