Reduce bots priority with mod_rails (passenger)

78 views Asked by At

With my current thin setup I can reduce bots priority redirecting them to one specific server instance with a lower priority:

# put some bots in one proxy port
RewriteCond %{HTTP_USER_AGENT} (?:Googlebot|bing|Mediapartners|Adsbot|Feedfetcher) [NC]
RewriteRule ^.*$ http://localhost:50003%{REQUEST_URI} [P,QSA]
# deny other bots
RewriteCond %{HTTP_USER_AGENT} baidu [NC,OR]
RewriteCond %{HTTP_USER_AGENT} bot [NC]
RewriteRule ^.*$ - [F] 
# deny empty user-agent
RewriteCond %{HTTP_USER_AGENT} ^-?$
RewriteRule ^.*$ - [F] 

And then lowering its priority by running

renice 20 `cat tmp/pids/thin.50003.pid`

But I have no idea on how to do that with Passenger, since it doesn't use a balancer. This is pretty much necessary for my server...

1

There are 1 answers

0
Hongli On BEST ANSWER

You can use Phusion Passenger's Standalone mode to achieve this. Start a Standalone server with 1 process at low priority:

nice passenger start -p 50003 -e production

Now Passenger will be listening on port 50003, and you can continue using your existing rewrite rules and proxy rules.