{"type":"rich","version":"1.0","provider_name":"phorkie","provider_url":"https:\/\/p.cweiske.de\/","title":"http 404 fallback multiple servers","author_name":"Christian Weiske","cache_age":86400,"width":900,"height":900,"html":"<!-- embedding all files of https:\/\/p.cweiske.de\/742 -->\n<link rel=\"stylesheet\" href=\"https:\/\/p.cweiske.de\/css\/embed.css\"\/>\n<div class=\"phork\" id=\"742\">\n    <div class=\"phork-file\">\n <div class=\"phork-content\">\n  \n<div class=\"document\">\n\n\n<p>nginx:<\/p>\n<ul class=\"simple\">\n<li><a class=\"reference external\" href=\"https:\/\/stackoverflow.com\/questions\/28332001\/how-to-configure-nginx-to-try-two-upstreams-before-404ing\/28337170\">https:\/\/stackoverflow.com\/questions\/28332001\/how-to-configure-nginx-to-try-two-upstreams-before-404ing\/28337170<\/a><\/li>\n<li>source: <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\">http:\/\/web.archive.org\/web\/20200723123257\/http:\/\/linuxplayer.org\/2013\/06\/nginx-try-files-on-multiple-named-location-or-server<\/a><\/li>\n<\/ul>\n<\/div>\n\n <\/div>\n <div class=\"phork-meta\">\n  <a href=\"https:\/\/p.cweiske.de\/742\/rev-raw\/c59f5e4781562779cbbafdc10f0f3c68ec010d9d\/README.rst\" style=\"float: right\">view raw source<\/a>\n  <a href=\"https:\/\/p.cweiske.de\/742#README.rst\">README.rst<\/a>\n <\/div>\n<\/div>\n    <div class=\"phork-file\">\n <div class=\"phork-content\">\n  <style type=\"text\/css\">\/**\n * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2014 Benny Baumann\n * (http:\/\/qbnz.com\/highlighter\/ and http:\/\/geshi.org\/)\n *\/\n.ini .de1, .ini .de2 {font: normal normal 1em\/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}\n.ini  {font-family:monospace;}\n.ini .imp {font-weight: bold; color: red;}\n.ini li, .ini .li1 {color: #DDD;}\n.ini .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}\n.ini .co0 {color: #666666; font-style: italic;}\n.ini .sy0 {color: #000066; font-weight:bold;}\n.ini .st0 {color: #933;}\n.ini .re0 {color: #000066; font-weight:bold;}\n.ini .re1 {color: #000099;}\n.ini .re2 {color: #660066;}\n.ini span.xtra { display:block; }\n<\/style><div class=\"code\"><table class=\"ini\"><tbody><tr class=\"li1\"><td class=\"ln\"><pre class=\"de1\">1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n<\/pre><\/td><td class=\"de1\"><pre class=\"de1\">location \/ <span class=\"br0\">&#123;<\/span>\n&#160; &#160; # Send 404s to B\n&#160; &#160; error_page <span class=\"nu0\">404<\/span> <span class=\"sy0\">=<\/span><span class=\"sy0\"><span class=\"re2\"> @backendB;<\/span><\/span>\n&#160; &#160; proxy_intercept_errors on;\n&#160; &#160; log_not_found &#160;off;\n&#160;\n&#160; &#160; # Try the proxy like normal\n&#160; &#160; proxy_set_header X-Forwarded-For $remote_addr;\n&#160; &#160; proxy_set_header Host $host;\n&#160; &#160; proxy_set_header X-Real-IP &#160;$remote_addr;\n&#160; &#160; proxy_pass http:\/\/A;\n<span class=\"br0\">&#125;<\/span>\n&#160;\nlocation @backendB <span class=\"br0\">&#123;<\/span>\n&#160; &#160; # If A didn't work, let's try B.\n&#160; &#160; proxy_set_header X-Forwarded-For $remote_addr;\n&#160; &#160; proxy_set_header Host $host;\n&#160; &#160; proxy_set_header X-Real-IP &#160;$remote_addr;\n&#160; &#160; proxy_pass http:\/\/B;\n&#160;\n&#160; &#160; # Any 404s here are handled normally.\n<span class=\"br0\">&#125;<\/span><\/pre><\/td><\/tr><\/tbody><\/table><\/div>\n <\/div>\n <div class=\"phork-meta\">\n  <a href=\"https:\/\/p.cweiske.de\/742\/rev-raw\/c59f5e4781562779cbbafdc10f0f3c68ec010d9d\/nginx.conf\" style=\"float: right\">view raw source<\/a>\n  <a href=\"https:\/\/p.cweiske.de\/742#nginx.conf\">nginx.conf<\/a>\n <\/div>\n<\/div>\n    <div class=\"phork-file\">\n <div class=\"phork-content\">\n  <style type=\"text\/css\">\/**\n * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2014 Benny Baumann\n * (http:\/\/qbnz.com\/highlighter\/ and http:\/\/geshi.org\/)\n *\/\n.ini .de1, .ini .de2 {font: normal normal 1em\/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}\n.ini  {font-family:monospace;}\n.ini .imp {font-weight: bold; color: red;}\n.ini li, .ini .li1 {color: #DDD;}\n.ini .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}\n.ini .co0 {color: #666666; font-style: italic;}\n.ini .sy0 {color: #000066; font-weight:bold;}\n.ini .st0 {color: #933;}\n.ini .re0 {color: #000066; font-weight:bold;}\n.ini .re1 {color: #000099;}\n.ini .re2 {color: #660066;}\n.ini span.xtra { display:block; }\n<\/style><div class=\"code\"><table class=\"ini\"><tbody><tr class=\"li1\"><td class=\"ln\"><pre class=\"de1\">1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n<\/pre><\/td><td class=\"de1\"><pre class=\"de1\">location \/static\/ <span class=\"br0\">&#123;<\/span>\n&#160; &#160; &#160; &#160; try_files $uri @static_svr1;\n<span class=\"br0\">&#125;<\/span>\nlocation @static_svr1<span class=\"br0\">&#123;<\/span>\n&#160; &#160; &#160; &#160; proxy_pass http:\/\/192.168.1.11$uri;\n&#160; &#160; &#160; &#160; proxy_intercept_errors on;\n&#160; &#160; &#160; &#160; recursive_error_pages on;\n&#160; &#160; &#160; &#160; error_page <span class=\"nu0\">404<\/span> <span class=\"sy0\">=<\/span><span class=\"sy0\"><span class=\"re2\"> @static_svr2;<\/span><\/span>\n<span class=\"br0\">&#125;<\/span>\n&#160;\nlocation @static_svr2<span class=\"br0\">&#123;<\/span>\n&#160; &#160; &#160; &#160; proxy_pass http:\/\/192.168.1.12$uri;\n&#160; &#160; &#160; &#160; proxy_intercept_errors on;\n&#160; &#160; &#160; &#160; recursive_error_pages on;\n&#160; &#160; &#160; &#160; error_page <span class=\"nu0\">404<\/span> <span class=\"sy0\">=<\/span><span class=\"sy0\"><span class=\"re2\"> @static_svr3;<\/span><\/span>\n<span class=\"br0\">&#125;<\/span>\n&#160;\nlocation @static_svr3<span class=\"br0\">&#123;<\/span>\n&#160; &#160; &#160; &#160; proxy_pass http:\/\/192.168.1.13$uri;\n<span class=\"br0\">&#125;<\/span><\/pre><\/td><\/tr><\/tbody><\/table><\/div>\n <\/div>\n <div class=\"phork-meta\">\n  <a href=\"https:\/\/p.cweiske.de\/742\/rev-raw\/c59f5e4781562779cbbafdc10f0f3c68ec010d9d\/nginx2.conf\" style=\"float: right\">view raw source<\/a>\n  <a href=\"https:\/\/p.cweiske.de\/742#nginx2.conf\">nginx2.conf<\/a>\n <\/div>\n<\/div>\n<\/div>\n"}
