I want to block all bots (like a HTTrack) on my website. Normally, I would use .htaccess file to block bots via RewriteCond %{HTTP_USER_AGENT} HTTrack [NC,OR]
.
However, my server is running Node.js Express. How can I get HTTP_USER_AGENT and do a block or rewritecond on Node.js?
There is a middleware for that, called express-nobots:
var noBots = require('express-nobots');
// must be the first middleware
app.use(noBots());
You can see the list of blocked bots inside a source file.