Logging nginx cookies with dashes

Strangely nginx does not support variable names with dashes or other characters other than lower/uppercase letters, digits or underscores. This means that if you are trying to log cookie values which contain dashes, as in my case, you can’t do it.

Two workarounds are logging the all the cookies in one go, which can be overwhelming:

The other option is to map your cookie names to a variable that can be used by nginx:

  • Manuel

    Remember to insert map out of the server declaration.