"Missing remote_user in NGINX logs with Nextcloud and LDAP authentication"

Hello everyone,

I have a Nextcloud server running version 27.1.11 on Ubuntu 22.04, with NGINX version 1.18.0 (Ubuntu) and PHP 8.2-FPM. Authentication is set up through LDAP.

My question is about the NGINX logs: I’m not seeing the remote_user field, even though this parameter is specified in the log_format directive in nginx.conf. When I check /phpinfo.php, both $_SERVER['HTTP_X_REMOTE_USER'] and $_SERVER['REMOTE_USER'] show as no value.

How can I fix this so that remote_user appears correctly?

Thanks in advance for any help!

Nginx log_format:

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

The output nginxlog in /var/log/____:

10.1.1.8 - - [12/Nov/2024:10:39:52 +0300] "GET /apps/files/api/v1/stats HTTP/1.1" 200 267 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36" 10.1.1.28

Isn’t $remote_user only for basic authentification?

We initially set up authentication through LDAP, and for a while, logging worked correctly — user information appeared in the NGINX logs. However, now the user data is missing from the logs.

I’d appreciate any ideas on what might have caused this issue and how to restore proper logging.