Hi,
I need to configure/modify nginx to use it in a 2-phase proxy kind of
configuration in which:
- use the hash value of one of the arguments in the original uri to
find the index of the first backend server (defined in an upstream) that
needs to be called,
- generate a separate request from the original request and send it to
the server specified in the previous stage,
- parse the output of the first call and generate a second request and
send it to the second backend server (possibly defined through another
upstream),
- return the reply from the second server back to the user
I am guessing that given the complexity, I would probably need to modify
nginx, or possibly write a new module. I am wondering if anyone has any
suggestions, maybe it is possible to do it with just modifying the
configuration(??), maybe there is something similar that is already
built in which I can use to modify, if not, what nginx module (proxy,
addition_filter, …?) I need to modify or use to write my own module.
Thanks,
-M
On Mon, Jan 26, 2009 at 7:19 PM, Mohammad K.
[email protected] wrote:
Hi,
I need to configure/modify nginx to use it in a 2-phase proxy kind of
configuration in which:
- use the hash value of one of the arguments in the original uri to find
the index of the first backend server (defined in an upstream) that needs to
be called,
- generate a separate request from the original request and send it to the
server specified in the previous stage,
- parse the output of the first call and generate a second request and
send it to the second backend server (possibly defined through another
upstream),
Maybe it will be enough to use the X-Accel-Redirect feature?
Mike
Is it possible to have a configuration similar to the following:
location /x {
proxy_pass http://www.yahoo.com;
}
location /y {
add_before_body /x;
add_after_body http://www.google.com;
}
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!
Thanks,
-M
On Wed, Jan 28, 2009 at 08:55:53PM +0100, Valery K. wrote:
Probably this should work:
location /y {
add_before_body @x;
add_after_body @x;
}
No, add_before_body does not support named locations.
On Wed, Jan 28, 2009 at 11:21:35AM -0800, Mohammad K. 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;
}
Probably this should work:
location /y {
add_before_body @x;
add_after_body @x;
}
location @x {
proxy_pass http://www.yahoo.com;
}