Nextcloud behind haproxy - login post delayed 30s

Hello,

I have a nextcloud installation behind an haproxy - accessing nextcloud is very performant except for the response to the login http post. With default timeouts I get a 504 Gateway time out at the 30 second point. When I increase the timeout over 30 seconds login is successful and everything is speedy following that. If I reduce the timeout to 5 seconds in haproxy and relogin I receive the 504 Gateway time out at the 5 second point but tailing the apache access log on the back end I only see the POST hit the log at the 30 second point.

Does anyone have a suggestion where to point me?

Thanks.

Can you provide the haproxy log (in httplog format) when this timeout occurs?

Thanks for the reply. Apology if I am not giving you the log entry in the format you are requesting, I am not too familiar with the package and am grabbing these from syslog. I am running using a pfsense plugin. Log entry 1 is when I have a timeout for the backend set at 5 seconds to trigger the quick timeout, the second below is when I have the timeout set to 31 seconds to “make it work”. For the first entry I have found the following context for the sH on stackoverflow.
s: the server-side timeout expired while waiting for the server to send or receive data.
H: the proxy was waiting for complete, valid response HEADERS from the server (HTTP only).

Thanks again for your time.

May 9 22:15:25 gatewayhost haproxy[78342]: internalip:58638 [09/May/2018:22:14:55.202] example_multipledomains-merged~ ocdirect_be_http_ipvANY/ulutil 0/0/1/-1/30007 504 194 - - sH-- 0/0/0/0/0 0/0 “POST /index.php/login HTTP/1.1”

May 9 22:19:54 gatewayhost haproxy[17336]: internalip:58752 [09/May/2018:22:19:23.542] example_multipledomains-merged~ ocdirect_be_http_ipvANY/ulutil 0/0/0/30703/30736 303 669 - - ---- 1/1/0/1/0 0/0 “POST /index.php/login HTTP/1.1”