Forum: NGINX Re: question about addition filter

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
412dd488538ddb80d5a48f4be68baf35?d=identicon&s=25 Mohammad Kolahdouzan (Guest)
on 2009-01-28 22:45
(Received via mailing list)
Igor,

I tried your config, with 0.7.32 and 0.7.31, with/without debug,
with/without optimization, but I constantly get garbage before and after
the content of /y/index.html. Maybe it is returning some uninitialized
memory?

I might be totally wrong, but Evan's module development tutorial
mentions something about NGX_AGAIN and that we should return NGX_AGAIN
if ngx_http_subrequest returns NGX_AGAIN. But looking in to your code,
ngx_http_addition_filter_module.c, line numbers 154 and 183, you are
always returning NGX_ERROR if ngx_http_subrequest does not return
NGX_OK. Could that be the reason?

Thanks,
-M

ps, I doubt it matters, but I have CentOS 5.2 64 bit.





________________________________
From: Igor Sysoev <is@rambler-co.ru>
To: nginx@sysoev.ru
Sent: Wednesday, January 28, 2009 12:04:35 PM
Subject: Re: question about addition filter

On Wed, Jan 28, 2009 at 11:21:35AM -0800, Mohammad Kolahdouzan wrote:

>
> which would supposedly add the content of the www.yahoo.com and www.google.com before 
and after the content of the page at /y/index.html? The addition filter module states that 
the texts after add_before_body and add_after_body are URI, but the above config doesn't 
seem to be doing it!

This should work, but it's better to use 0.7.32 for this:

         location = /x {
             proxy_pass http://www.yahoo.com/;
         }

         location = /g{
             proxy_pass  http://www.google.com/;
         }

         location /y {
             add_before_body /x;
             add_after_body  /q;
         }
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2009-01-28 22:49
(Received via mailing list)
On Wed, Jan 28, 2009 at 01:28:50PM -0800, Mohammad Kolahdouzan wrote:

> ps, I doubt it matters, but I have CentOS 5.2 64 bit.
This may be gzipped content returned by external sites:

          location = /x {
              proxy_pass http://www.yahoo.com/;
+             proxy_set_header  Accept-Encoding  "";
          }

          location = /g{
              proxy_pass  http://www.google.com/;
+             proxy_set_header  Accept-Encoding  "";
          }
412dd488538ddb80d5a48f4be68baf35?d=identicon&s=25 Mohammad Kolahdouzan (Guest)
on 2009-01-28 23:19
(Received via mailing list)
That was the problem, the content was zipped, everything is working now.

Thanks,
-M




________________________________
From: Igor Sysoev <is@rambler-co.ru>
To: nginx@sysoev.ru
Sent: Wednesday, January 28, 2009 1:39:50 PM
Subject: Re: question about addition filter

On Wed, Jan 28, 2009 at 01:28:50PM -0800, Mohammad Kolahdouzan wrote:

> ps, I doubt it matters, but I have CentOS 5.2 64 bit.
This may be gzipped content returned by external sites:

          location = /x {
              proxy_pass http://www.yahoo.com/;
+             proxy_set_header  Accept-Encoding  "";
          }

          location = /g{
              proxy_pass  http://www.google.com/;
+             proxy_set_header  Accept-Encoding  "";
          }
412dd488538ddb80d5a48f4be68baf35?d=identicon&s=25 Mohammad Kolahdouzan (Guest)
on 2009-01-28 23:44
(Received via mailing list)
What if I wanted to write a module that does something like this: if
input request is something like http://localhost/y?a=foo&b=bar, then
have the before_body fetch yahoo.com/foo and after_body get the content
of google.com/bar (i.e., the URLs can bo modified on the fly). Is this
doable, possibly by modifying the content of uri that is passed to
ngx_http_subrequest, or is there another alternative?

Thanks,
-M





________________________________
From: Igor Sysoev <is@rambler-co.ru>
To: nginx@sysoev.ru
Sent: Wednesday, January 28, 2009 1:39:50 PM
Subject: Re: question about addition filter

On Wed, Jan 28, 2009 at 01:28:50PM -0800, Mohammad Kolahdouzan wrote:

> ps, I doubt it matters, but I have CentOS 5.2 64 bit.
This may be gzipped content returned by external sites:

          location = /x {
              proxy_pass http://www.yahoo.com/;
+             proxy_set_header  Accept-Encoding  "";
          }

          location = /g{
              proxy_pass  http://www.google.com/;
+             proxy_set_header  Accept-Encoding  "";
          }
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2009-01-29 09:03
(Received via mailing list)
On Wed, Jan 28, 2009 at 02:34:54PM -0800, Mohammad Kolahdouzan wrote:

> What if I wanted to write a module that does something like this: if input request is 
something like http://localhost/y?a=foo&b=bar, then have the before_body fetch 
yahoo.com/foo and after_body get the content of google.com/bar (i.e., the URLs can bo 
modified on the fly). Is this doable, possibly by modifying the content of uri that is 
passed to ngx_http_subrequest, or is there another alternative?

Currently add_xxxx_body does not support variables.
If it could, then it would be possible:

          location /x/ {
              proxy_pass http://www.yahoo.com/;
          }

          location /g/ {
              proxy_pass  http://www.google.com/;
          }

          location /y {
              add_before_body /x/$arg_a;
              add_after_body  /q/$arg_b;
This topic is locked and can not be replied to.