Hi,
Today I'm in need of some help.
I have the following scenario.
One of my sites is quite old (10 years or more), and has more and less 50GB of uploads. In order to save disk space, I move the old uploads (2020 and before) to a Backblaze B2 account, and redirect the traffic to these uploads with:
rewrite /wp-content/uploads/2020/(.*) https://b2.full.url/2020/$1 permanent;
It works well enough, but it's not easy to maintain, and if I happen to upload something new in an older post (quite common), I have to remember to upload it to B2. And the recent months also become a nightmare, because every month I have to add several new rewrite rules before I can rewrite the whole year.
How could I rewrite (or ideally proxy_pass
) only the request to non existent files in local filesystem?
I tried the code below, with no success:
location ^/wp-content/uploads/(.*) {
try_files $uri @b2proxy;
}
location @b2proxy {
proxy_pass https://b2.full.url/;
}
Thanks!