Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to modify cookies when using nginx as a reverse proxy similar to what Set-Cookie does in apache?

I have a web application that sets session cookies and I wish to append the HttpOnly flag to them before they are served by nginx. Unfortunatly I cannot modify the source code of the application to do it there.

share|improve this question
Possible duplicate of…. Seems to be that the same "It's not possible" and methods for resolving it apply. – Kyle Smith Apr 1 '12 at 21:50
didn't tried it, but I suppose that you can modify the header via – hellvinz May 23 '12 at 9:32

You can always use add_header to add one, but even if you parse cookies coming down from backend looking at the http_cookie variable, you won't be able to modify them using vanilla nginx.

What you could use however is the 3rd-party Lua module. The link provided by Kyle Sith has an answer containg a small code snippet manipulating cookies (

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.