Nginx Valid Referer - Access Control - Help Wanted

AshleyinSpain nginx-forum at forum.nginx.org
Wed Feb 5 19:43:38 UTC 2020


I want to use nginx referer module to restrict access to a URL containing a
directory /radio/ 
Only allowing access to it from a link with http referer *.mysite.*
(anysubdomain.mysite.anytld) otherwise redirect to 403

Is the referer module already loaded in nginx if not how do I load it

I found various code examples to add to the conf file and coupled this
together and added it to the end of the conf file, but it doesn't work,
entering a URL directly into the browser serves it

<code>
server {
    location /radio/ {
        valid_referers none blocked server_names ~\.mysite\.;
    if ($invalid_referer) {
        return 403;
        }
    }
}
</code>

Should just the location bit of code be added inside an existing server
block 

My set up is nginx in docker on Ubunto 18 on a Digital Ocean droplet

Any help would be appreciated, been working on this for days

Best regards
Ashley

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,286958,286958#msg-286958



More information about the nginx mailing list