I need to parse nginx access_log
and associate records with user accounts. To do so, I decided to use a custom header:
- App sends custom header (like
x-userid
) - Nginx stores that value in access_log with custom log format
$sent_http_x_userid
- The header is being cleared and so the client doesn't see it with
more_clear_headers 'x-userid'
Logging works just fine, I can see the proper userids in access_log. However, if I turn on the clearing part, the access_log shows '-' instead of actual userid.
Am I doing something wrong? Is it possible to log the header from the app before sending it to the client and then empty it with nginx?
Is there a better way to make this work? The app is PHP7, nginx is 1.10.3