Xwiki timeouts after LDAP-autentication is used

Xwiki started to have timeouts after LDAP-authentication was implemented with openLDAP. Xwiki responds “nginx 504 gateway timeout” after 4-5 hours of idle. After timeout if browser cache is cleared or private mode used it starts to work again. Firefox is used. This issue was not present before LDAP-authentication.