HTTP to HTTPS Redirection

We are now in the security spectrum. So far, we have created our own website/blog and learned a bit about WordPress editing.

HTTPS is the standard for most websites as it uses TLS/SSL certificates to encrypt communication and lets you know who I am and my webserver know who you are. Adding this feature will ensure that your data is safe from prying eyes. Let’s start!

Difficulty: ♦♦*

Cost: $0

Services:

  • WordPress-Bitnami
  • AWS LightSail

The snippet below confirms that we are indeed using HTTP. The problem with using this protocol is that we are using unencrypted communication via hypertext structured text, this means that all the traffic can be intercepted and read. Meaning that any usernames, passwords, server/client requests, and cookies can be seen as plain text.

Let’s change that!

First, we need to make sure that our DNS Zones map our domain to our IP address on our instance. SSH to your terminal or from the terminal button on AWS Lightsail and enter the command:

host www.You-Domain-Address.com

*you should recieve the ip address on your instance*

If you don’t get the IP address to your instance, don’t worry; ill post a mini troubleshooting section that will address any other issues that may come up, including this one.

Next! Let’s go ahead and execute the following commands

sudo /opt/bitnami/bncert-tool

Domain list [] : www.Your_Domain.com Your_Domain.com

Enable HTTP to HTTPS redirection [Y/n]: Y

Enable non-www to www redirection [Y/n]: n

Enable www to non-www redirection [y/N]: n

Do you agree to these changes? [Y/n]: y

E-mail address []: EmailAddr_Associated_ToDomain_Registration@You_EmailProvider.com

Do you agree to the Let’s Encrypt Subscriber Agreement? [Y/n]: Y

Press [Enter] to continue: {Enter}

Let’s refresh the webpage, and you should see a padlock indicating the use of HTTPS. Dig a bit deeper; we can check the certificate to very the domain and issuing organization:

Troubleshooting

  • If your domain is not resolving to your IP address, ensure that your DNS Zone in Lightsail is configured as follow:
    • A Records: Root Domain | Click add record >> Record Type “A” >> Record Name “@” >> Resolves To “Domain.IP.Address” >> Save
    • A Records: Root Domain | Click add record >> Record Type “A” >> Record Name “*” >> Resolves To “Domain.IP.Address” >> Save
    • CNAME: Record Type: CNAME >> Record Name “www” >> Save
  • If {host www.Your_Domain.com} does not resolve an IP address:
    • It’s more than likely that you don’t have the ‘www’ subdomain as a CNAME record. Change it to reflect the above snippet.
  • When submitting the domains in bncert-tool you get “The domain does not resolve; please fix its DNS entries or remove it”
    • Check your DNS is configured correctly. Verify IP to Domain by using https://www.whatsmydns.net
    • If the problem persists: you can bypass the validation of the tool by using the following command
      • sudo /opt/bitnami/bncert-tool –perform_public_ip_validation 0 –perform_dns_validation 0
  • If previous media and/or background are not displaying, this is a known issues as your media follow the URL path of your WordPress URL address located in Settings >> General >> WordPress Address. To fix this, use the following:

cd /opt/bitnami/wordpress

nano wp-config.php

Scroll down

add an “s” to http on ‘WP_HOME’ & ‘WP_SITEURL’

Ctrl + x >> Y >> Enter

I hope this worked out for you; if it did not work, please reach out directly on my linked in by clicking HERE. This project is far from over; more security implementations still need to be added. Please go to my project tab and continue with the project that follows.