Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ngnix to proxy server B only if got 404 on server A

Tags:

nginx

proxy

I'm trying to configure nginx (0.7.65) so it'll proxy to server A, and if it gets 404 will try to proxy to server B.

I've tried the following, but it doesn't work. Any ideas?

    server {
    error_log  /tmp/nginx.error.log;
    access_log   /tmp/nginx.access.log;
    listen 4433;
    server_name localhost;

    location / {
        proxy_pass http://localhost:5984;
        error_page 404 = @fallback;
    }

    location @fallback {
        proxy_pass http://localhost:5983;
    }
}
like image 945
lazy1 Avatar asked May 26 '10 22:05

lazy1


People also ask

Can NGINX act as proxy?

Nginx is an open source web server that can also serve as a reverse proxy.

How does NGINX reverse proxy work?

A reverse proxy server is a type of proxy server that typically sits behind the firewall in a private network and directs client requests to the appropriate backend server. A reverse proxy provides an additional level of abstraction and control to ensure the smooth flow of network traffic between clients and servers.

Is NGINX reverse proxy or forward proxy?

Nginx is often used as a load balancer, a reverse proxy, and an HTTP Cache, among other uses. In this tutorial, we are focusing on learning how to use it as a forward proxy for any requested location.


1 Answers

    proxy_intercept_errors on;
like image 186
lazy1 Avatar answered Oct 18 '22 20:10

lazy1