I’m using nginx to do a redirect if a user direct access image by browser. The problem is it doesn’t work when you use Cloudflare, it will no longer redirect. Here is a live version for you to test with: link
nginx config
location ~ "^/c/600x1200_90_webp/img-master/img/\d+/\d+/\d+/\d+/\d+/\d+/((?<filenum>\d+)[^/]+\.(jpg|png|webp))$" {
proxy_pass http://195.xxx.xxx.xxx:5694;
valid_referers server_names demo.adoreanime.com;
if ($invalid_referer = "1") {
add_header Cache-Control "no-cache";
return 301 https://demo.adoreanime.com/artwork/$filenum;
}
}
Is there anyway to fix this without disabling Cloudflare? I want to still able to cache and redirect