new to this site so i'll keep it brief:
I have currently:
if ($http_user_agent ~* (A-certain-self-made-User-Agent-here)) {
return 200;
}
Which works very well. (Tested by switching 200 to 403).
My question is: Is there a way in: /etc/nginx/sites-enabled/default to make it allow only ONE User-Agent and deny the rest?
I know this seems stupid, but it's something i'd like to have done, (if possible). Like maybe this?:
if (http_user_agent ~*(user-agent)) {
return 200;
else
return 403;
}
Click on 'Add exception' and the Whitelist Rules for Bot Access window will pop up. Under the dropdown menu, select 'User agent' and key in 'AhrefsBot' and 'AhrefsSiteAudit' then click 'Confirm'.
To configure the user-agent block list, open the nginx configuration file for your website. This file can be found in different places depending on your nginx setup or Linux distribution (e.g.: /etc/nginx/nginx. conf, /etc/nginx/sites-enabled/<your-site>, /usr/local/nginx/conf/nginx. conf, /etc/nginx/conf.
It's just a string that a browser optionally sends to the server. Firefox can let you change the string entirely via the about:config page by modifying/creating the string general. useragent.
Try this:
if ($http_user_agent !~* (A-certain-self-made-User-Agent-here)) {
return 403;
}
This should be a 'not match' on your certain user agent. Reference info here: HttpRewriteModule
if ($http_user_agent !~* "A-certain-self-made-User-Agent-here") {
return 403;
}
is working on my site.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With