Welcome! Log In Create A New Profile

Advanced

proxy_pass to upstreams and then 404 location

April 17, 2015 12:59AM
Hello all -

I'm attempting to do the following in nginx and having difficulty with the last step in this succession.

1) In / location, proxy_pass to Django upstream.
2) proxy_intercept_errors is on in this block and does a proxy_pass to PHP upstream if 404 is returned.
3) In PHP location block (internal), proxy_intercept_errors is on and if a 404 is returned, goes to 404 location block.
4) The 404 location block should proxy_pass to the same Django upstream, but pass /404/ to the Django app.

Everything but the final 404 proxy_pass is working fine. I can send a "bad" URL that will return a 404 from Django and PHP upstreams, but when I tail the Django app logs, the "bad" URL is what is sent to the upstream when I would like /404/ sent to the upstream. I do not need the URL to be re-written to domain.com/404/ in the client browser.

Thank you in advance for any help/recommendations.

location / {
log_not_found off;

expires 1m;

proxy_intercept_errors on;
proxy_pass http://django;
error_page 404 = @php;
}

location @django {
internal;
log_not_found off;

proxy_redirect off;
proxy_pass http://django$uri$is_args$args;
}


location @php {
internal;
log_not_found off;

include conf.d/proxypass.conf;
proxy_redirect off;
proxy_intercept_errors on;
proxy_pass http://php$uri$is_args$args;
error_page 404 = /404/;
}

location /404/ {
log_not_found off;
proxy_pass http://django;
}
Subject Author Posted

proxy_pass to upstreams and then 404 location

daveyfx April 17, 2015 12:59AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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