2 Nextcloud instances behind load balance not working


I want to have Nextcloud load balanced on two servers, so I tried to run Nextcloud running behind a haproxy via https. Both backends are working individually. But as soon as I enable both with round-robin, I get a lot of error messages especially in the admin menus (e.g. users, apps, log). Additionally, login doesn’t work on the first try and the files app sometimes reloads after 5 seconds.

When I open the developer view of my browser I see a lot of “HTTP 412” Precondition failed errors and on logout I get a CSRF Error. My guess is that there is some problem with the HTTPS encryption, because I switch servers in between.

Is there any solution for this?

I had the same issue.
The only work around i found is to use “sticky sessions” in the load balancer, instead of round-robin for example.

Its not clear why a round robin approach doesn’t work, especially as i have a Redis instance for distributed memory cache