Welcome! Log In Create A New Profile

Advanced

Switching error_page within the same location directive

Posted by shadowfiend 
Switching error_page within the same location directive
September 27, 2010 06:38PM
I've got a proxy set up:

[code]
location ~ ^(.*)$ {
proxy_pass http://127.0.0.1:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header Host $host;

proxy_buffering off;
proxy_read_timeout 3600;

proxy_intercept_errors on;

error_page 500 /50x-running.html;
error_page 404 /404-running.html;
}
[/code]

My problem is, for a specific sub-URI, I want a different error_page directive. In particular, anything starting with /item should have a different error_page. The problem is I still want the proxy directives above applied. I tried:

[code]
location ~ ^/items {
error_page 404 /404-items.html;
}
[/code]

But this simply ignores the proxy directives and shows this 404 always. Likewise if I nest it within the above location directive (which I gather isn't particularly supported anyway). Is there any way, other than creating a new block with the same proxy directives and a different error_page directive, to do this?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

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