Proxy_pass directive not being honored/incorrect proxy_pass being used

Background:

  • 2 web servers behind load balancers; gentoo as OS but different
    “versions”

  • server1 has gcc 3.3.5 server2 has gcc 4.1.1

  • compile options --with-http_ssl_module --with-debug --user=daemon
    –group=daemon

  • apache 2.0.53 nginx-0.7.61 php-5.2.1
    Setup:

  • We were using apache to proxy to amazon cdn but it was getting too
    slow;
    enter nginx

  • nginx doesn’t serve anything directly, it acts solely as a proxy to
    apache
    and amazon

  • we got it working but we want to redirect to apache everytime a php
    file
    is requested

  • config snippet:
    location ~* .php$ {
    proxy_pass http://apache;

          proxy_set_header   Host             $host;
          proxy_set_header   X-Real-IP        $remote_addr;
          proxy_set_header   X-Forwarded-For 
    

$proxy_add_x_forwarded_for;
proxy_max_temp_file_size 0;

        client_max_body_size       100m;
        client_body_buffer_size    128k;

        proxy_connect_timeout      90;
        proxy_send_timeout         90;
        proxy_read_timeout         90;
        proxy_buffer_size          4k;
        proxy_buffers              4 32k;
        proxy_busy_buffers_size    64k;
        proxy_temp_file_write_size 64k;
    }

    location /amazonpath {
        rewrite            /amazonpath/(.*) /$1 break;
        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For 

$proxy_add_x_forwarded_for;
proxy_pass http://amazon.uri;
proxy_redirect off;
}

> however, it proxies to amazon even when we request a php file
  • here is where it gets honky; server1 proxies to amazon but server2
    proxies
    to our apache as expected; so i thought it was libpcre, server2 had 6.6
    while server1 had 5.5; we update libpcre on server1 to latest which is
    7.9-r1, but same problem exists on server1;

  • i re-compiled nginx --with-debug and got this on server1
    [debug] 32319#0: *4588 test location: “amazonpath”
    [debug] 32319#0: *4588 test location: ~ “.php$”
    [debug] 32319#0: *4588 using configuration “.php$”

  • so it goes to the right location directive but proxies to amazon
    instead
    to our apache

anybody have any ideas ?

occam’s razor or murphy’s law either way desk apply to forehead :-((

virtual config on apache in server1 still had proxy_pass directive on,
took
that out, now it works. nginx was/is working as intended