tags:

views:

123

answers:

1

I'm trying to get nginx to always proxy certain requests, even if a static file exists. I have the proxying working fine, except nginx seems to insist on serving a static version of the file even if a proxy directive has been declared.

So in the config below, if a file named "/siteroot/static/members/page.html" existed, it would be (incorrectly) served directly instead of proxying, but if I remove the file, then proxying proceeds as expected. How can I force nginx to always proxy?

I'm running nginx 0.7.67, here's the full config:

worker_processes  1;

error_log  logs/error.log;
pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    access_log  logs/access.log;

    sendfile        on;
    keepalive_timeout  65;
    tcp_nodelay        on;

    gzip  on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";
}

server {
    listen       80;
    server_name  .XXX.net .XXXnet.net;
    server_name_in_redirect off;

    location ^~ /members {
             access_log logs/members-access.log;
             proxy_pass http://127.0.0.1:5010;
    }

    location ^~ /search {
             access_log logs/search-access.log;
             proxy_pass http://127.0.0.1:5010;
    }

    location / {
             root /siteroot/static;
    }


    # redirect server error pages to the static page /50x.html
    error_page    404  %(ROOT)s/web/XXX/public/404.html;
    error_page    500 502 503 504  %(ROOT)s/web/XXX/public/50x.html;
}
A: 

After turning on nginx debugging, it turns out that nginx is correctly reverse-proxying to the back-end application. It is the back-end Pylons application that is serving the static file as-is instead of executing a controller. Nginx seems to be functioning properly.

Rick Morrison