Joined: 03 Aug 2007 Posts: 412 Location: A'dam/Diemen, The Netherlands
Posted: Wed Nov 04, 2015 9:14 am Post subject: [nginx] multiple fallback locations (try each one)
Update 1: see reply below for a much better version
This proxy setup will fetch all content from @static_svr1, and if not found (proxy_intercept_errors) it will get it from the original server @static_svr2
Feel free to chain this to have some more.
Code:
server {
listen 80; #Port that my custom app was assigned
server_name domain.ext www.domain.ext;
location / {
try_files $uri @static_svr1;
}
location @static_svr1{
proxy_pass http://fallbackurl.ext;
proxy_intercept_errors on;
error_page 404 = @static_svr2;
}
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum