3

I have the following configuration in nginx:

    location /api/ {
        auth_request /auth/request/;

        auth_request_set $user $upstream_http_remote_user;
        proxy_set_header Remote-User $user;
      

        proxy_pass http://...;
    }

I am setting the Remote-User field, so I would expect that in the access log, the value would appear, but it's only - that appear, indicating the value does not exist. In the server proxied there, I can access the header Remote-User, so I know that the value is well set, but can't manage to display it in the access logs.

I suppose the access log are generated before the auth request maybe.

Is there a way to get the Remote-User inside the access logs with this kind of configuration?

hanego
  • 1,595
  • 1
  • 14
  • 27

1 Answers1

2

in you nginx.conf you should have something like

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

replace $remote_user by your $user variable

plusdepseudo
  • 91
  • 1
  • 1
  • 6