Welcome! Log In Create A New Profile

Advanced

RE: nginx filter to concat text to a response body

Filipe Silva
September 22, 2012 01:30AM
Hi Zhu,
I tried taobao's module and it works like a charm if nginx is configured as a web server:
server {
listen 80;
server_name localhost;

location / {
footer "<!-- $date_gmt -->";
index index.html;
}
}
The result is a html comment with a gmt date like <!-- 1234567890 --> added to the end of the response body.
But if configured like a reverse proxy it does not add the comment.
server { listen 80; server_name localhost;
location / { proxy_pass http://127.0.0.1:8080/;
footer "<!-- $date_gmt -->"; }}
Well, this simple nginx location configuration points the traffic to a upstream web server. As expected, on return I don't get the nginx's default index.html, but the upstream html page instead, with the difference that the comment <!-- 1234567890 --> is not added.
I'm pretty sure I'm missing something here. I'm starting to believe that if I want to write to a response body served by a upstream server a filter may not be the answer.
I've tried evanmiller.org guide and I found the section "3.2. Anatomy of an Upstream (a.k.a Proxy) Handler" (http://www.evanmiller.org/nginx-modules-guide.html#proxying) and I have the impression that this might help me finding the answer, but I'm failing to reproduce the example because at the moment I'm not as familiar with the guts of an handler as I am with a filter.
Anyway, I don't even know if an handler will do the trick. So any help is welcome :)
Thank you.

Date: Sat, 22 Sep 2012 01:45:40 +0800
Subject: Re: nginx filter to concat text to a response body
From: zhuzhaoyuan@gmail.com
To: nginx-devel@nginx.org

Hi Filipe,

On Sat, Sep 22, 2012 at 12:01 AM, Filipe Silva <fs20063@outlook.com> wrote:




Hello,
I've been trying to produce a nginx filter to concat text to a response body but without success.

An important detail is that it works with a nginx configured as a web server but not with a nginx server configured as reverse proxy.

Should I be using an handler instead?
Is this what you are looking for?
https://github.com/taobao/nginx-http-footer-filter
Regards,
--
Joshua Zhu
Senior Software Engineer

Server Platforms Team at Taobao


_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel _______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

nginx filter to concat text to a response body

Filipe Silva 1283 September 21, 2012 12:04PM

Re: nginx filter to concat text to a response body

Joshua Zhu 538 September 21, 2012 01:46PM

RE: nginx filter to concat text to a response body

Filipe Silva 535 September 22, 2012 01:30AM

Re: nginx filter to concat text to a response body

Joshua Zhu 575 September 22, 2012 02:24AM

RE: nginx filter to concat text to a response body

Filipe Silva 1179 September 22, 2012 04:24AM

Re: nginx filter to concat text to a response body

Joshua Zhu 511 September 22, 2012 04:56AM

RE: nginx filter to concat text to a response body

Filipe Silva 547 September 22, 2012 06:04AM

Re: nginx filter to concat text to a response body

Igor Sysoev 765 September 22, 2012 02:36AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

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