I have a setup of the website that powered by 2 web applications under the hood.
One application (fast) is supposed to handle catalog pages.
Another application (slow) is supposed to handle customer/cart/checkout pages.
Both applications should run on the same host:
example.com:80 (fast) and example.com:8000 (slow)
Of course, port 8000 is not exposed for the visitor and used internally by nginx.
I want that web requests reach slow application only if fast application returned specific response header, for example X-catalog-not-found.
The expected result is following:
- all requests go to
fastapplication example.com:80 - if
fastapplication found a product by uri - it renders the page - if
fastapplication did not find a product by uri - it sends empty body and response header X-catalog-not-found - based on the header received in prev step, nginx performs proxy pass to
slowapplication example.com:8000
I feel that ngx_http_proxy_module or/and nginx_upstream module should be used, but haven't found a working solution after reading the docs.