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

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?


PS: here is an extract from my conf:
http {

upstream backend {
consistent_hash $request_uri;

upstream backend_hr {
consistent_hash $request_uri;

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 {
Sorry, only registered users may post in this forum.

Click here to login

Online Users

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