<div dir="ltr">Hi all,<div><br></div><div style>I've been experimenting with rewriting 'Set Cookie' headers in a nginx-reverse-proxy effort.</div><div style><br></div><div style>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.</div>

<div style><br></div><div style><div>http {</div><div><br></div><div>server {</div><div>     access_log /home/bhedia/access.log;</div><div>     #error_log /home/bhedia/errors.log debug;</div><div>     error_log /home/bhedia/errors.log notice;</div>

<div><br></div><div>     listen   80;</div><div><br></div><div>     root /usr/share/nginx/www;</div><div>     #index index.html index.htm;</div><div><br></div><div>     # Make site accessible from <a href="http://localhost:8080/">http://localhost:8080/</a></div>

<div>     server_name localhost;</div><div><br></div><div>     location / {</div><div><br></div><div>          proxy_pass           <a href="http://10.45.17.85:50088/">http://10.45.17.85:50088/</a>;</div><div>          proxy_set_header     Host <a href="http://booga.booga.com">booga.booga.com</a>;</div>

<div>          #proxy_cookie_domain    <a href="http://test-sites.com">test-sites.com</a> <a href="http://booga.booga.com">booga.booga.com</a>;</div><div>         </div><div>          header_filter_by_lua '</div><div>

<span class="" style="white-space:pre">       </span>       ngx.log(ngx.NOTICE, "hello world")</div><div>               local cookies = ngx.header.set_cookie</div><div>               if not cookies then return end</div>

<div>               if type(cookies) ~= "table" then cookies = {cookies} end</div><div>               local newcookies = {}</div><div>               for i, val in ipairs(cookies) do</div><div>                   local newval = string.gsub(val, "([dD]omain)=[%w_-\\\\.-]+",</div>

<div>                          "%1=<a href="http://booga.booga.com">booga.booga.com</a>")</div><div><span class="" style="white-space:pre">         </span>   ngx.print(val)</div><div><span class="" style="white-space:pre">          </span>   ngx.print(newval)</div>

<div>                   table.insert(newcookies, newval)</div><div>               end</div><div>               ngx.header.set_cookie = newcookies</div><div>              ';</div><div>     }</div><div>}</div><div>}</div>

<div><br></div><div style>Any help would be appreciated.</div><div style><br></div><div style>Thanks!</div></div></div>