Stopping server overload, cleaning up the site front page, disabling comments, and general goodness

Date: Sat Apr 05 2014 Drupal Planet
The last few days the server hosting this site was overloaded, and I finally took a look at the access log, saw a continuous stream of requests that shouldn't be occurring, and realized the "links" row of teasers on the front page needed to go away. The default links row includes one reading "Log in to post comments" but this blog doesn't allow anybody else to register for an account, and in any case comments are handled by Disqus rather than Drupal's commenting system. The link didn't need to be there at all, and the more I looked at the links row the more useless it looked.

Here's the sort of request that was driving the server into the ground. Whatever agent it was, kept hammering at this and very similar URL's, at a rate of dozens per minute. The server load was skyrocketing, site unusable, etc.


GET /user/login?destination=comment/reply/7734%23comment-form HTTP/1.0

Things did improve when I enabled the boost module - which I'd thought had already been configured, but it wasn't. Boost didn't do the whole trick though, because that agent kept hammering at these URL's. Of course it was doing so because of the unnecessary "Log in to post comments" link.

The "Log in to post comments" link is useless for this site because it refers to Drupal native comments, which aren't being used at all because this site uses Disqus. Once we say that link needs to go then every one of the other links are superfluous. The "Read more" simply duplicates the link that's in the title of the teaser. Do readers really need a link to "David Herron's blog"? The comment count is arguably useful because it gives some social credence, but I don't care enough about it to preserve the links row.

There isn't a direct setting to turn off the "Log in to post comments" link, unfortunately. Upon searching for how to do so I wandered across a discussion thread on Drupal.org giving some complex methods of turning this off. A custom module, or whatnot. The simplest is a new capability, just go into the Content Type configuration, and set comments to be Closed or Hidden by default. Any new nodes that are created will inherit that setting, but existing nodes won't be changed to have their comments Closed or Hidden.

To change all the nodes so comments are Closed, run this SQL command:


mysql> update node set comment = 1;

If instead you want comments to be Hidden, set the value to "0" instead.

Doing that much removes the "Log in to post comments" link. But it still leaves the links line in place.

Turns out there's a trivial way of removing the links row. Create a View to override the front page, and in the Teaser config simply uncheck the "Teaser Links" box.

That is, Views ships with a View for /frontpage that's meant to emulate the system front page. It's disabled by default, so I went to that and cloned the View. In the cloned version of the View, click on the Teaser choice and uncheck the box marked "Display Links". Save it, and then visit your /frontpage URL.

This is cleaner in my eye.. the Links row is just extra stuff that got in the way of seeing the content. I'm glad it's gone.

The next step is to head over to the Site Information admin screen, and change your home page to /frontpage

This leaves a problem, the old homepage is still visible at /node. If Google were to stumble across that page (which it surely will) the site will get dinged a bit for duplicate content.

I found this http://drupal.stackexchange.com/questions/24132/disable-node-summary-page-on-node-path which discusses a simple little module to return an access denied error for requests to /node. An important consideration is that in disabling /node you not disable requests to /node/NNNN so that your content is still available.

But there's something even simpler to do. In that View (Clone of Front Page), simply change its path to /node. You'll also have to revert the Site Information admin page to show a blank in the frontpage configuration. This way the View now does the display for the /node page, replacing the default /node page which comes from the Node module.

It should also be possible to create a Panel page that overrides /node if you want to create a completely different sort of home page. But I haven't checked this.

By the way - the stream of /user/login?destination=comment/reply/7734%23comment-form requests has completely stopped, the server load is fixed, the site home page looks better, I'd say lots of goodness has been created.