• Hi, Pleskians! We are running a UX testing of our upcoming product intended for server management and monitoring.
    We would like to invite you to have a call with us and have some fun checking our prototype. The agenda is pretty simple - we bring new design and some scenarios that you need to walk through and succeed. We will be watching and taking insights for further development of the design.
    If you would like to participate, please use this link to book a meeting. We will sent the link to the clickable prototype at the meeting.
  • Our UX team believes in the in the power of direct feedback and would like to invite you to participate in interviews, tests, and surveys.
    To stay in the loop and never miss an opportunity to share your thoughts, please subscribe to our UX research program. If you were previously part of the Plesk UX research program, please re-subscribe to continue receiving our invitations.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

Resolved Where to put apache and nginx global rewrite rules?

tkalfaoglu

Silver Pleskian
I have this code for our main site to stop the pesky crawlers in our main site's hosting settings:

Apache & nginx Settings for kalfaoglu.net :

Code:
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} (SemrushBot|PetalBot|DotBot|gumgum-bot|postmanruntime|ag_dm_spider|scrapy|chimebot|trendkite-akashic-crawler|ZoominfoBot|Sogou|ALittle|Keybot|Buck|curl|webpr
osbot|RestSharp|Snap|SemrushBot|AhrefsBot|DataForSeoBot|Sogou|trendkite-akashic-crawler|cortex|ALittle|Go-http-client|RestSharp) [NC]
RewriteRule .* - [F,L]

and for nginx:

Code:
if ($http_user_agent ~ (SemrushBot|PetalBot|DotBot|gumgum-bot|postmanruntime|ag_dm_spider|scrapy|chimebot|trendkite-akashic-crawler|ZoominfoBot|Sogou|ALittle|Keybot|Buck|curl|webprosbot|RestSharp|Snap|SemrushBot|AhrefsBot|Da
taForSeoBot|Sogou|trendkite-akashic-crawler|cortex|ALittle|Go-http-client|RestSharp|MJ12bot)) {
        return 403;
}

I would like to make this applied to all sites we host. How do I go about making this globally for every site we host/will host?

Many thanks, -t
 
You could put those directives in your own file in /etc/httpd/conf.d and /etc/nginx/conf.d
Use a filename like "zzz_mytweaks.conf" or similar to make sure it is included as the last file
 
Many thanks! I created that zzz_mytweaks.conf, did a httpdmng --reconfigure-domain, but I do not see my changes in the vhost.conf of that domain. Am I suppose to see them there? I mean, how can I tell if my conf is included in the httpd conf?
 
Many thanks! I created that zzz_mytweaks.conf, did a httpdmng --reconfigure-domain, but I do not see my changes in the vhost.conf of that domain. Am I suppose to see them there? I mean, how can I tell if my conf is included in the httpd conf?
In fact, I don't see it anywhere in the /etc/httpd (recursively searched) or in /var/www/vhosts/kalfaoglu.net/conf directories.. I only see it my zzz_mytweaks file. Shouldn't I see it in my kalfaoglu.net conf files too?

Thanks!
 
Shouldn't I see it in my kalfaoglu.net conf files too?

Nope, you won't see those files anywhere except where you've created them (/etc/httpd/conf.d/zzz_mytweaks.conf and/or /etc/nginx/conf.d/zzz_mytweaks.conf)
Once you've created them, a simple reload of Apache + nginx is enough

Note: If you're on Debian or Ubuntu, the Apache global config is in /etc/apache2/conf.d

See also: Apache and Nginx Configuration Files
 
Back
Top