title: In Nginx, redirect to another site if img is down
body: <p>I have a site using some old link pngs, like :</p>
  
  <pre><code>&lt;img src="http://j.cd.top/uploads/jvyue/news/2020/04/10/15864804147273771862.png" style="height:211px; width:330px"&gt;
  </code></pre>
  
  <p>and the png is not present, so I tried to rewrite it to a local server by setting Nginx:</p>
  
  <pre><code>    location ~ .*\.(gif|jpg|jpeg|png)$ {
           try_files $uri @apache; }
      location @apache{
          rewrite  ^http://j.cd.top/uploads/(.*)$  http://127.0.0.1:8222/$1 permanent;
      }
  </code></pre>
  
  <p><a href="http://127.0.0.1:8222" rel="nofollow noreferrer">http://127.0.0.1:8222</a> is local server that server images, but this settings not works, is something wrong?</p>
  
  <p><a href="http://j.cd.top/uploads" rel="nofollow noreferrer">http://j.cd.top/uploads</a> is not the current website, it is a legacy link.</p>
  
  <p>I also tried proxy pass :</p>
  
  <pre><code> location ~* \.(gif|jpg|jpeg|png)$ {
           proxy_pass http://127.0.0.1:8222;
       }
  </code></pre>