Welcome! Log In Create A New Profile

Advanced

Proxying to 2 backends with a if...

Posted by jdm 
jdm
Proxying to 2 backends with a if...
January 17, 2011 06:40AM
Hi,

I setup two servers, each proxying to a different backend, one http and one fcgi, and it mostly worked.
Now, I am trying to setup one server that would proxy to the two different backends based on the presence of args or a header...
So I merged both configurations, but I have some issues like many configuration parameters do not work inside a 'if'.
I moved most outside the if, but I am not sure of the effects.
And the headers don't seem to be proxied to the fcgi backend...
Could some knowledgeable people offer some advice on how to fix my configuration file?

Thanks,
JD

PS: here is an extract from my conf:
[code]
http {

upstream backend {
consistent_hash $request_uri;
server 192.168.80.1:999;
server 192.168.80.2:999;
}

upstream backend_hr {
consistent_hash $request_uri;
server 192.168.80.1:888;
server 192.168.80.2:888;
}

server {

location / {

# If there are query params or a Range header, pass first to hr.php
set $to_hr 0;
if ($args) {
set $to_hr 1;
}
if ($http_range) {
set $to_hr 1;
}

# ----- call hr.php before squid ----------------------------------
root /WEBS;
fastcgi_index hr.php;
set $script_name $uri;
set $path_info "";
if ($uri ~ "^(.+.php)(/.+)") {
set $script_name $1;
set $path_info $2;
}
include fastcgi_params_from_uri;
if ($to_hr) {
rewrite ^/(.+)$ /hr.php/$1 break;
fastcgi_pass backend_hr;
}

# ----- straight to squid -----------------------------------------
if ($to_hr = FALSE) {
proxy_pass http://backend;
}
error_page 500 502 404 405 = @fallback;
}

location @fallback {
proxy_pass http://192.168.80.1:999;
}
}
[/code]
Sorry, only registered users may post in this forum.

Click here to login

Online Users

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