Can't log/print in header_filter_by_lua

Ramesh Muraleedharan ramesh1987 at
Mon May 20 21:20:56 UTC 2013

Hi all,

I've been experimenting with rewriting 'Set Cookie' headers in a
nginx-reverse-proxy effort.

The Set-Cookie rewrite doesn't seem to work yet, and more importantly, my
log/print statements don't print to error_log as directed, making it very
difficult to debug.

http {

server {
     access_log /home/bhedia/access.log;
     #error_log /home/bhedia/errors.log debug;
     error_log /home/bhedia/errors.log notice;

     listen   80;

     root /usr/share/nginx/www;
     #index index.html index.htm;

     # Make site accessible from http://localhost:8080/
     server_name localhost;

     location / {

          proxy_pass ;
          proxy_set_header     Host;

          header_filter_by_lua '
       ngx.log(ngx.NOTICE, "hello world")
               local cookies = ngx.header.set_cookie
               if not cookies then return end
               if type(cookies) ~= "table" then cookies = {cookies} end
               local newcookies = {}
               for i, val in ipairs(cookies) do
                   local newval = string.gsub(val,
                   table.insert(newcookies, newval)
               ngx.header.set_cookie = newcookies

Any help would be appreciated.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list