Welcome! Log In Create A New Profile

Advanced

Help grabbing single option from upstream header.

Posted by pir8radio 
Help grabbing single option from upstream header.
January 10, 2016 09:11PM
Hello, new to the forum.... I have a header being sent from the upstream server that looks like this:

x-authorization:Client="Web Client", Device="Chrome 47.0.2526.106", DeviceId="3a3591f34aa7bf0cbda943edb993dbf11ecf0f4e", Version="3.0.5805.0", UserId="1de587e5988kdsede6f60a4f50d545e0"

I need to grab the "UserId" value ONLY, and log it in the nginx access log in place of the normal $remote_user.

Some more info, I do not have access to change the upstream headers, otherwise i would just create a new userid header. This is what I have to work with.. :-)


Any help would be greatly appreciated.. I really have no clue how to even start on this one.. lol



Edited 2 time(s). Last edit at 01/10/2016 09:17PM by pir8radio.
Re: Help grabbing single option from upstream header.
January 10, 2016 09:29PM
Actually that is a request header from the client..

Thanks.
Re: Help grabbing single option from upstream header.
January 11, 2016 08:20PM
not many users on the forums hu? No one?
Re: Help grabbing single option from upstream header.
September 29, 2016 06:04PM
Well, i guess this is a useless forum lol....
Re: Help grabbing single option from upstream header.
September 30, 2016 01:30PM
https://www.google.nl/#q=nginx+log+header+from+upstream
https://forum.nginx.org/read.php?2,217896,217896#msg-217896

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: Help grabbing single option from upstream header.
September 30, 2016 03:21PM
Yea....... I know how to log a header... Please READ my post... its asking how do i log the SINGLE UserId value... This header contains multiple comma delimited values for the single header value "X-authorization" it contains a Client, Device, DeviceId, Version, AND UserId.. I only want to grab the UserId... Neither of those searches answers that question.
Re: Help grabbing single option from upstream header.
September 30, 2016 03:48PM
You asked "header being sent from the upstream server" and thats what those results show.
If you want to log a part of such value you could try a regex via 'map', or a regex via Lua but Lua can't write to normal nginx logfiles.

---
nginx for Windows http://nginx-win.ecsds.eu/
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 281
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready