nginx error_page directive to proxy contents of a static url
I am trying to use error_page like the following, to trap errors, and then
read content from an external url, and send that to the client:
error_page 404 =404 @err404;
location @err404 {
proxy_pass http://www.myserver.com;
}
This is in the "server" directive. I want any 404 to be caught by this (it
is) - and then the content from http://www.myserver.com read - and
returned as the body of the 404 returned to the client.
This almost works - but when I try to access
http://myserver/somenonexistingURL, proxies through to
http://www.myserver.com/somenonexistingURL - which seems unhelpful - is
there a way to have it just proxy the content of exactly what I typed? Not
proxy the entire request?
If I put
error_page 404 http://backend
Then I get a 30X redirect (as per the docs) - which is not what I want
either.
Any ideas?
Docs: http://wiki.nginx.org/HttpCoreModule#error_page and
http://nginx.org/en/docs/http/ngx_http_core_module.html#error_page
No comments:
Post a Comment