1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | location / { # Send 404s to B error_page 404 = @backendB; proxy_intercept_errors on; log_not_found off; # Try the proxy like normal proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://A; } location @backendB { # If A didn't work, let's try B. proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://B; # Any 404s here are handled normally. } |