Welcome! Log In Create A New Profile

Advanced

Re: Can't log/print in header_filter_by_lua

May 20, 2013 05:50PM
I've tried print() as well, and neither that nor ngx.log() have worked as
yet.


On Mon, May 20, 2013 at 2:42 PM, Jader H. Silva <jaderhs5@gmail.com> wrote:

> *ngx.print()* is only valid for r*ewrite_by_lua*, access_by_lua* and
> content_by_lua*.* Maybe your looking for* print()
>
> ngx.log* should work though*.
> *
>
> *
> *
>
>
> 2013/5/20 Ramesh Muraleedharan <ramesh1987@gmail.com>
>
>> 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 http://10.45.17.85:50088/;
>> proxy_set_header Host booga.booga.com;
>> #proxy_cookie_domain test-sites.com booga.booga.com;
>>
>> 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,
>> "([dD]omain)=[%w_-\\\\.-]+",
>> "%1=booga.booga.com")
>> ngx.print(val)
>> ngx.print(newval)
>> table.insert(newcookies, newval)
>> end
>> ngx.header.set_cookie = newcookies
>> ';
>> }
>> }
>> }
>>
>> Any help would be appreciated.
>>
>> Thanks!
>>
>> _______________________________________________
>> nginx mailing list
>> nginx@nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx
>>
>
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Can't log/print in header_filter_by_lua

bhedia May 20, 2013 05:22PM

Re: Can't log/print in header_filter_by_lua

Jader H. Silva May 20, 2013 05:44PM

Re: Can't log/print in header_filter_by_lua

bhedia May 20, 2013 05:50PM

Re: Can't log/print in header_filter_by_lua

bhedia May 20, 2013 08:20PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 138
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