Latest posts

Browse topics

How To Redirect in Nginx all Domain Name Versions to https://www

As you might already know search engines (Google) sees www.domain.com and domain.com as two separate domain names. If you are not using 301 redirects (www to non-www or vice verse)you might get penalized for duplicate content. 

In Ngnix, there is a simple solution how to make such redirect happen, see: Ngnix Redirect To WWW

Now, things get a bit complicated when https versions are involved. See: Linode: How To Secure Nginx with Let's Encrypt on Ubuntu 12.04

Once your website has https enabled, technically speaking you might be dealing with for different domain names:

  1. domain.com
  2. www.domain.com
  3. https://domain.com
  4. https://www.domain.com

What we are looking is to redirect all versions to one, I prefer the version with https://www, here is how to achieve that with Nginx server blocks.

Assuming you have already configured server blocks pointing your domain name to https://www open your server config:

sudo nano /opt/etc/nginx/sites-available/reinisfischer.com

And at the end of the code add:

server{
  listen 80;
  server_name www.reinisfischer.com reinisfischer.com;
  return 301 https://$server_name$request_uri;
}
server{
  listen 443;
  server_name reinisfischer.com;
  return 301 https://www.$server_name$request_uri;
}

Now, restart Nginx

sudo /etc/init.d/nginx restart

Hope it helps!

How To Update Drupal Modules via SSH (Putty)

To strengthen Drupal websites security I decided to disable one-click automatic module updates from Drupal dashboard, unfortunately, it makes it harder not even for bad guys to compromise Drupal website but it also makes it harder for Drupal devs.

Now, there are several options you might choose instead, composer being a top of them. But for this article, I will write down how to update modules using SSH.

For Windows, we are going to use Putty:

From your Drupal installation go to the modules folder

cd /sites/all/modules

now, using wget download desired modules and extract:

sudo wget https://ftp.drupal.org/files/projects/file_entity-7.x-2.21.tar.gz
sudo tar -xvzf file_entity-7.x-2.21.tar.gz

Go back to the Drupal website and run updates. Next, you would like to delete tar.gz file from the modules folder

sudo rm file_entity-7.x-2.21.tar.gz

Tapping Birch Sap in the Backyard

Can't decide on a new hobby? Think about tapping birch sap in early spring. Depending on the region you are located and availability of birch trees you might even enjoy this drink - a birch sap.

In today's article a few photos from tapping a birch sap in early spring in our backyard using Libertu Birch Sap Kit.

You can purchase this kit at sula.lv to get your own tree sap. If you have maple or birch trees in your yard or forest you can get juice very easy. 

Libertu Birch Sap Kit

Libertu Birch Sap Kit

Bought this kit at the local DIY shop. It was a fun, trying to install it and trying to squeeze a juice from this birch

Plastic bag for collecting birch sap

Plastic bag for collecting birch sap

We left this kit in a tree for about two weeks to collect birch sap.

Securing Drupal Files and Folders (Chmod, Security Review, Hacked)

There are a couple of great helper modules for Drupal to learn more about failing security holes - Security Review and Hacked. 

Security Review

The Security Review module automates testing for many of the easy-to-make mistakes that render your site insecure.

Security Review runs the following checks:

  • Safe file system permissions (protecting against arbitrary code execution)
  • Text formats don't allow dangerous tags (protecting against XSS)
  • PHP or Javascript in content (nodes and comments and fields in Drupal 7)
  • Safe error reporting (avoiding information disclosure)
  • Secure private files
  • Only safe upload extensions
  • A large number of database errors (could be a sign of SQLi attempts)
  • A large amount of failed logins (could be a sign of brute-force attempts)
  • Responsible Drupal admin permissions (protecting against access misconfiguration)
  • Username as password (protecting against brute-force)
  • Password included in user emails (avoiding information disclosure)
  • PHP execution (protecting against arbitrary code execution)
  • Base URL set / D8 Trusted hosts (protecting against some phishing attempts)
  • Views access controlled (protecting against information disclosure)

This module does not automatically make changes to your site. You should use the results of the checklist and its resources to manually secure your site. The results of some checks may be incorrect depending on unique factors of your site.

Here are the results showing issues with a Drupal 7 installation

Security Review

Security Review

Hacked

This module scans the currently installed Drupal, contributed modules and themes, re-downloads them, and determines if they have been changed. Changes are marked clearly and if the diff module is installed then Hacked! will allow you to see the exact lines that have changed.

This module does not and will not prevent your site from being 'hacked'.

Chmod permissions for files and folders

The Drupal security guide has a section on securing your site with a useful list of items to work through.

There are several approaches to set file permissions for a Drupal website, most common include chmod 755 for sites/default/folder and chmod 644 for public files

If you are using Security Review module,you should investigate step by step, but here is an example for securing your drupal website public_html folder

sudo chmod -R 555 public_html

Let me know!

Kitesurfing Pāvilosta

Seems Pāvilosta is a popular spot for kitesurfing among surfers from the Baltics. It was on mid-June 2017 we decided to visit lovely white sand beaches near Pāvilosta piers when I noticed some kitesurfer gathering. Seems there was a good wind that day.

As I was equipped with my gear and a telephoto glass - I made some photography here. A piece of Life, after all. 

Kitesurfing in Pāvilosta

Kitesurfing in Pāvilosta

Actually, I'm not sure what is the name of this activity - kitesurfing or kiteboarding. According to Wikipedia:

Kiteboarding is an action sport combining aspects of wakeboarding, snowboarding, windsurfing, surfing, paragliding, skateboarding and sailing into one extreme sport. A kiteboarder harnesses the power of the wind with a large controllable power kite to be propelled across the water, land, or snow. On water, a kiteboard, similar to a wakeboard or a small surfboard, with or without footstraps or bindings, is used. Kitesurfing is a style of kiteboarding specific to wave riding, which uses standard surfboards or boards shaped specifically for the purpose. On land, a mountain board or foot steered buggy is used while skis or snowboards can be used in snow,

Kitsurfer preparing

Kitesurfer preparing

Probably he has just landed? 

Seagulls having fun at Pāvilosta beach

Seagulls having fun at Pāvilosta beach