How to force nginx rewrite to return 200 status code?
伊谢尔伦
伊谢尔伦 2017-05-16 17:27:56
0
2
744
               if (!-e $request_filename){
               rewrite "^/maisi/images/(.*)\.jpg" http://img03.taobaocdn.com/.jpg_300x300.jpg last;
               rewrite "^/maisi/images/(.*)\.png" http://img03.taobaocdn.com/.png_300x300.jpg last;
             }

The above is an nginx image rewrite. In fact, my image is a Taobao image!

This will return 302 Moved Temporarily;

Is there a way to return 200 OK

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(2)
洪涛

Because rewrite returns 302, the browser will know that it needs to make another request, and then go to Taobao's cdn to get the image. If 200 is returned, all this will not happen

If you cannot copy the file, you can consider using proxy_pass. In this case, it is equivalent to nginx reading the image from taobao to your server every time, and then your server sends the image to the user, which can return 200 Yes, but the pressure on the server will increase

仅有的幸福
location = /example/path {
    return 200;
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template