Nginx URL Fallback setup with internal redirection in reverse-proxy settings

Hi
List Members Gurus

                      I have installed and configured a virtual

host using NGINX in Ubuntu 14.04 Now I want to add couple of
functionalities like–

Set up Nginx config so that any URL address which is not found, goes
to a fallback path with internal redirection (NO change or redirection
in browser URL).

Assuming the following:
Fallback path needed for configuration:
http://myvirtualhost/fallback_directory/fallbackhandler.php
Anything typed after http://localhost when not found, should hit the
fallback path (internal redirection, meaning NO change or redirection
in browser address bar). The
fallback path is given above
(http://app_servers/fallback_directory/fallbackhandler.php) which
needs to be setup in Nginx config.

For example, when i visits www.test.com/not_existing_directory/ and
not_existing_directory doesn’t exist, it should hit the fallback path
while still retaining www.test.com/not_existing_directory/ in browser
address bar.

Please point me to NGINX resources and a steps that will be required
so that I can grasp NGINX quickly to do the above task.

Thanks in advance
Ashish

On Fri, Jun 19, 2015 at 10:59:00PM +0530, Ashish k wrote:

Hi there,

Set up Nginx config so that any URL address which is not found, goes
to a fallback path with internal redirection (NO change or redirection
in browser URL).

Please point me to NGINX resources and a steps that will be required
so that I can grasp NGINX quickly to do the above task.

It sounds like you want your own handler for 404 errors. So

error_page 404 @404;

or

error_page 404 = @404;

Module ngx_http_core_module for details. and the difference between
the two lines.

Then in “location @404 {}”, do what you want - proxy_pass or
fastcgi_pass
to something external with appropriate other settings, most likely.

Good luck with it,

f

Francis D. [email protected]