<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed><type>rich</type><version>1.0</version><provider_name>phorkie</provider_name><provider_url>https://p.cweiske.de/</provider_url><title>http 404 fallback multiple servers</title><author_name>Christian Weiske</author_name><cache_age>86400</cache_age><width>900</width><height>900</height><html>&lt;!-- embedding all files of https://p.cweiske.de/742 --&gt;
&lt;link rel="stylesheet" href="https://p.cweiske.de/css/embed.css"/&gt;
&lt;div class="phork" id="742"&gt;
    &lt;div class="phork-file"&gt;
 &lt;div class="phork-content"&gt;
  
&lt;div class="document"&gt;


&lt;p&gt;nginx:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="https://stackoverflow.com/questions/28332001/how-to-configure-nginx-to-try-two-upstreams-before-404ing/28337170"&gt;https://stackoverflow.com/questions/28332001/how-to-configure-nginx-to-try-two-upstreams-before-404ing/28337170&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;source: &lt;a class="reference external" href="http://web.archive.org/web/20200723123257/http://linuxplayer.org/2013/06/nginx-try-files-on-multiple-named-location-or-server"&gt;http://web.archive.org/web/20200723123257/http://linuxplayer.org/2013/06/nginx-try-files-on-multiple-named-location-or-server&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

 &lt;/div&gt;
 &lt;div class="phork-meta"&gt;
  &lt;a href="https://p.cweiske.de/742/rev-raw/c59f5e4781562779cbbafdc10f0f3c68ec010d9d/README.rst" style="float: right"&gt;view raw source&lt;/a&gt;
  &lt;a href="https://p.cweiske.de/742#README.rst"&gt;README.rst&lt;/a&gt;
 &lt;/div&gt;
&lt;/div&gt;
    &lt;div class="phork-file"&gt;
 &lt;div class="phork-content"&gt;
  &lt;style type="text/css"&gt;/**
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2014 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 */
.ini .de1, .ini .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.ini  {font-family:monospace;}
.ini .imp {font-weight: bold; color: red;}
.ini li, .ini .li1 {color: #DDD;}
.ini .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.ini .co0 {color: #666666; font-style: italic;}
.ini .sy0 {color: #000066; font-weight:bold;}
.ini .st0 {color: #933;}
.ini .re0 {color: #000066; font-weight:bold;}
.ini .re1 {color: #000099;}
.ini .re2 {color: #660066;}
.ini span.xtra { display:block; }
&lt;/style&gt;&lt;div class="code"&gt;&lt;table class="ini"&gt;&lt;tbody&gt;&lt;tr class="li1"&gt;&lt;td class="ln"&gt;&lt;pre class="de1"&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
&lt;/pre&gt;&lt;/td&gt;&lt;td class="de1"&gt;&lt;pre class="de1"&gt;location / &lt;span class="br0"&gt;&amp;#123;&lt;/span&gt;
&amp;#160; &amp;#160; # Send 404s to B
&amp;#160; &amp;#160; error_page &lt;span class="nu0"&gt;404&lt;/span&gt; &lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="sy0"&gt;&lt;span class="re2"&gt; @backendB;&lt;/span&gt;&lt;/span&gt;
&amp;#160; &amp;#160; proxy_intercept_errors on;
&amp;#160; &amp;#160; log_not_found &amp;#160;off;
&amp;#160;
&amp;#160; &amp;#160; # Try the proxy like normal
&amp;#160; &amp;#160; proxy_set_header X-Forwarded-For $remote_addr;
&amp;#160; &amp;#160; proxy_set_header Host $host;
&amp;#160; &amp;#160; proxy_set_header X-Real-IP &amp;#160;$remote_addr;
&amp;#160; &amp;#160; proxy_pass http://A;
&lt;span class="br0"&gt;&amp;#125;&lt;/span&gt;
&amp;#160;
location @backendB &lt;span class="br0"&gt;&amp;#123;&lt;/span&gt;
&amp;#160; &amp;#160; # If A didn't work, let's try B.
&amp;#160; &amp;#160; proxy_set_header X-Forwarded-For $remote_addr;
&amp;#160; &amp;#160; proxy_set_header Host $host;
&amp;#160; &amp;#160; proxy_set_header X-Real-IP &amp;#160;$remote_addr;
&amp;#160; &amp;#160; proxy_pass http://B;
&amp;#160;
&amp;#160; &amp;#160; # Any 404s here are handled normally.
&lt;span class="br0"&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
 &lt;/div&gt;
 &lt;div class="phork-meta"&gt;
  &lt;a href="https://p.cweiske.de/742/rev-raw/c59f5e4781562779cbbafdc10f0f3c68ec010d9d/nginx.conf" style="float: right"&gt;view raw source&lt;/a&gt;
  &lt;a href="https://p.cweiske.de/742#nginx.conf"&gt;nginx.conf&lt;/a&gt;
 &lt;/div&gt;
&lt;/div&gt;
    &lt;div class="phork-file"&gt;
 &lt;div class="phork-content"&gt;
  &lt;style type="text/css"&gt;/**
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2014 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 */
.ini .de1, .ini .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.ini  {font-family:monospace;}
.ini .imp {font-weight: bold; color: red;}
.ini li, .ini .li1 {color: #DDD;}
.ini .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.ini .co0 {color: #666666; font-style: italic;}
.ini .sy0 {color: #000066; font-weight:bold;}
.ini .st0 {color: #933;}
.ini .re0 {color: #000066; font-weight:bold;}
.ini .re1 {color: #000099;}
.ini .re2 {color: #660066;}
.ini span.xtra { display:block; }
&lt;/style&gt;&lt;div class="code"&gt;&lt;table class="ini"&gt;&lt;tbody&gt;&lt;tr class="li1"&gt;&lt;td class="ln"&gt;&lt;pre class="de1"&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
&lt;/pre&gt;&lt;/td&gt;&lt;td class="de1"&gt;&lt;pre class="de1"&gt;location /static/ &lt;span class="br0"&gt;&amp;#123;&lt;/span&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; try_files $uri @static_svr1;
&lt;span class="br0"&gt;&amp;#125;&lt;/span&gt;
location @static_svr1&lt;span class="br0"&gt;&amp;#123;&lt;/span&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; proxy_pass http://192.168.1.11$uri;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; proxy_intercept_errors on;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; recursive_error_pages on;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; error_page &lt;span class="nu0"&gt;404&lt;/span&gt; &lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="sy0"&gt;&lt;span class="re2"&gt; @static_svr2;&lt;/span&gt;&lt;/span&gt;
&lt;span class="br0"&gt;&amp;#125;&lt;/span&gt;
&amp;#160;
location @static_svr2&lt;span class="br0"&gt;&amp;#123;&lt;/span&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; proxy_pass http://192.168.1.12$uri;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; proxy_intercept_errors on;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; recursive_error_pages on;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; error_page &lt;span class="nu0"&gt;404&lt;/span&gt; &lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="sy0"&gt;&lt;span class="re2"&gt; @static_svr3;&lt;/span&gt;&lt;/span&gt;
&lt;span class="br0"&gt;&amp;#125;&lt;/span&gt;
&amp;#160;
location @static_svr3&lt;span class="br0"&gt;&amp;#123;&lt;/span&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; proxy_pass http://192.168.1.13$uri;
&lt;span class="br0"&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
 &lt;/div&gt;
 &lt;div class="phork-meta"&gt;
  &lt;a href="https://p.cweiske.de/742/rev-raw/c59f5e4781562779cbbafdc10f0f3c68ec010d9d/nginx2.conf" style="float: right"&gt;view raw source&lt;/a&gt;
  &lt;a href="https://p.cweiske.de/742#nginx2.conf"&gt;nginx2.conf&lt;/a&gt;
 &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</html></oembed>
