500 ajax error when installing plugin on cloudflare->load balanced setup

I have this setup

                                                                                      GlusterFS
                                                                                     /
https Cloudflare CDN/proxy -> https DO Load Balancer -> https 2xWordPress app -> 
                                                                                     \
                                                                                      MariaDB

And sometimes when I try to install a plugin I’m getting this error

Installation failed: <!DOCTYPE html> <!--[if lt IE 7]> <![endif]--> <!--[if IE 7]> <![endif]--> <!--[if IE 8]> <![endif]--> <!--[if gt IE 8]><!--> <!--<![endif]--> example.com | 504: Gateway time-out <!--[if lt IE 9]><![endif]--> 
body{margin:0;padding:0} Error 504 Ray ID: xxxxxxxxxxxxxx &bull; 
2018-10-29 01:12:34 UTC Gateway time-out 
<!-- /.error-overview --> 
You Browser Working 
Ashburn Cloudflare Working 
example.com Host Error 
<!-- /.status-display --> 
What happened? The web server reported a gateway time-out error. What can I do? Please try again in a few minutes. 
<!-- /.section --> 
Cloudflare Ray ID: xxxxxxxxxxxxxxx &bull; 
Your IP: xx.xxx.xx.xx &bull; 
Performance &amp; security by Cloudflare 
<!-- /.error-footer --> <!-- /#cf-error-details --> <!-- /#cf-wrapper -->

I’ve checked the apache error logs and they show nothing

Taking a look at the console and network tab I see this

Request URL: https://example.com/wp-admin/admin-ajax.php
Request Method: POST
Status Code: 500 
Remote Address: <Cloudflare ip>
Referrer Policy: strict-origin-when-cross-origin
Response Headers
access-control-allow-credentials: true
access-control-allow-origin: https://example.com
cache-control: no-cache, must-revalidate, max-age=0
cf-ray: xxxxxxxxxxxxxxx
content-type: text/html; charset=UTF-8
date: Mon, 29 Oct 2018 16:54:05 GMT
expect-ct: max-age=604800, report-uri="https://report-uri.Cloudflare.com/cdn-cgi/beacon/expect-ct"
expires: Wed, 11 Jan 1984 05:00:00 GMT
referrer-policy: strict-origin-when-cross-origin
server: Cloudflare
set-cookie: DO-LB=node-116903061|W9c7M|W9c6v; path=/
status: 500
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-robots-tag: noindex
Request Headers
:authority: example.com
:method: POST
:path: /wp-admin/admin-ajax.php
:scheme: https
accept: */*
accept-encoding: gzip, deflate, br
accept-language: en-US,en;q=0.9
content-length: 134
content-type: application/x-www-form-urlencoded; charset=UTF-8
cookie: wordpress_c18fe9c2f38c6b4ae3b42f875a382700=cafevagrant%7C1540937391%7CZglMpSo9ro1x70Vg4UtewAQ9T4i7KchOEdIEvIvOndQ%7C3be346a2eb0390e9168d8068525a79634f383b3bbdf3254dff1eb02882d4d003; wordpress_sec_33c9c4bdbcb5f673bf19a4c42fa20d9a=username%7C1540943095%7CI791z8Lm6mnnd1W0qqJ69j4k6sQlQZAqwdw1hJGPs59%7C79518c472ff478f34d932e9bd0bc4a02896f7488bf3fab327884636ac2d59e4f; __cfduid=d44ad0de93291cf1a58264aff9224ce2a1540716559; wordpress_test_cookie=WP+Cookie+check; wordpress_logged_in_c18fe9c2f38c6b4ae3b42f875a382700=cafevagrant%7C1540937391%7CZglMpSo9ro1x70Vg4UtewAQ9T4i7KchOEdIEvIvOndQ%7Cd5a6308149d6e080bd755ce2e5ddeaef3fc54d08f17493ccdc1c3111386956be; wordpress_logged_in_33c9c4bdbcb5f673bf19a4c42fa20d9a=cafevagrant%7C1540943095%7CI791z8Lm6mnnd1W0qqJ69j4k6sQlQZAqwdw1hJGPs59%7C5c0ccfa00d7efcee40f353c1c6c672f045d658de9b7518c519e1535475eecafa; wp-settings-time-1=1540832041; DO-LB=node-116903061|W9c7L|W9c6v
origin: https://example.com
referer: https://example.com/wp-admin/plugin-install.php?s=redis&tab=search&type=term
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.20 Safari/537.36
x-requested-with: XMLHttpRequest
Form Data
view source
view URL encoded
slug: redis-cache
action: install-plugin
_ajax_nonce: 8db3cbb6b5
_fs_nonce: 
username: 
password: 
connection_type: 
public_key: 
private_key: 

Any help would be appreciated!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.