Valid_referers configuration help

The current configuration is as follows:

    location ^~ /wp-content/uploads/20 {
        valid_referers xxx.cn *.xxx.cn *.google.com *.bing.com *.baidu.com;
        if ($invalid_referer) {
            return 302 $scheme://$host/additional/anti-theft.png;
        }
    }

I also want requests to /wp-content/uploads/2024/12/cropped-Blogger*.png to bypass the valid_referers check, so that they can be accessed normally regardless of whether there is a referrer.

How should the configuration be adjusted?

    location ^~ /wp-content/uploads/2024/12/cropped-Blogger { }
    location ^~ /wp-content/uploads/20 {
        valid_referers xxx.cn *.xxx.cn *.google.com *.bing.com *.baidu.com;
        if ($invalid_referer) {
            return 302 $scheme://$host/additional/anti-theft.png;
        }
    }

2 Likes

Thanks for coming back and sharing your solution!!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.