I have a set of rules in Nginx of this type:
location ~ ^/race/[a-z0-9\-_]*/session/[a-z0-9\-]*/topic/[a-z0-9\-_]*$ {
try_files $uri $uri/ /race/period/session/team/topic/index.html;
}
location /images/assets/ {
try_files /backup/data$uri /default_images/small_asset.png =404;
}
These rules work when the files exist on the server but now the data is in a remote location (AWS - S3+cloudfront) I need to use proxy_pass
, but wondering how to deal with cases when I have multiple choices like:
try_files $uri $uri/ /race/period/session/team/topic/index.html;
And
try_files /backup/data$uri /default_images/small_asset.png =404;
How to handle the first path in a remove endpoint for example:
location /images/assets/ {
proxy_pass http://abc.cloudfront.net/backup/data
# but if I get a 404 here,how to fall back to:
proxy_pass http://abc.cloudfront.net/default_images/small_assets.png
}
Any ideas? not necessary I need to use Nginx now that the content is hosted remotely, open to any alternatives.