• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Resolved User Agent Filtering

CiretPro

New Pleskian
User Agent Filtering

Hello, tell me if there is a possibility of filtering traffic by specifying a user agent based on nginx.

Interested in server and client level solutions by specifying additional nginx directives

Example for server level:

if ($ http_user_agent ~ (ZmEu | libwww-perl | wget)) {
return 403;
}

I submit to etc/nginx.conf but does not work.

Thanks
 
nginx does not support this on a global/server level and you have to add this configuration for every virtualhost.

So what you could do is:
1) create a file named /etc/nginx/baduagent.conf and put in what IgorG linked
2) create a custom template (/opt/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php) and add a "include baduagent.conf;" in an appropriate position
3) rebuild web configuration


You can also do it in Apache2, as here it's possible to configure it globally:

1) add file /etc/apache2/conf-enabled/baduagent.conf (this works for debian/ubuntu - for rpm based linux use similar/appropriate location) with the following content (add/remove/adjust UserAgents as needed)
Code:
# global blocking of bots we don't like
<IfModule setenvif_module>
  <Location />
        <If "%{HTTP_USER_AGENT} =~ /SemrushBot/">
                Require all denied
        </If>
        <If "%{HTTP_USER_AGENT} =~ /MJ12bot/">
                Require all denied
        </If>
        <If "%{HTTP_USER_AGENT} =~ /BLEXBot/">
                Require all denied
        </If>
        <If "%{HTTP_USER_AGENT} =~ /AhrefsBot/">
                Require all denied
        </If>
        <If "%{HTTP_USER_AGENT} =~ /DotBot/">
                Require all denied
        </If>
        <If "%{HTTP_USER_AGENT} =~ /XoviBot/">
                Require all denied
        </If>
        <If "%{HTTP_USER_AGENT} =~ /Seekport/">
                Require all denied
        </If>
  </Location>
</IfModule>
2) restart apache2 service




Advantage of nginx method is that it will save some (very few) resources, as requests do not need to go the Apache2 service first and it also works for websites where Apache2 is disabled completely. (i.e. nginx proxying is disabled)

Advantage of Apache2 method is that you do not need to fumble with the Plesk templates, because this became a pita with 18.0, as you need to check and possibly redo them on every Plesk update. (i.e. every couple days/weeks...)
 
Back
Top