Enable HTTPS on Wordpress in Amazon
Tech-Today

Enable HTTPS on Wordpress in Amazon


This tutorial will help us install Wordpress on Amazon using a Wordpress image provided by Bitnami. We will also enable HTTPS by using an Amazon's elastic load balancer and a WordPress plugin.

Steps

  1. Create an EC2 instance and install this Wordpress image from Bitnami: https://aws.amazon.com/marketplace/pp/B00NN8Y43U.
  2. Install Easy Https Redirection plugin on Wordpress - https://wordpress.org/plugins/https-redirection/
  3. Configure Elastic Load Balancing With SSL And AWS Certificate Manager For Bitnami Applications On AWS - https://docs.bitnami.com/aws/how-to/configure-elb-ssl-aws/
    These lines should be added before WP_HOME and WP_SITEURL:
    if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
    $_SERVER['HTTPS']='on';
  4. At this stage, your URL should both be accessible via HTTP and HTTPS, but we want to force a redirect to HTTPS so we need to do this final step.
    1. Reopen ~/apps/wordpress/conf/httpd-prefix.conf and add the following lines:
      RewriteCond %{HTTPS} !=on
      RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC]
      RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  5. And finally, don't forget to restart the apache server: /opt/bitnami/ctlscript.sh restart apache

The final version of the file should look like below. Take note of the commented lines, those are the originals.
SetEnvIf x-forwarded-proto https HTTPS=on

# App url moved to root
DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
#Alias /wordpress/ "/opt/bitnami/apps/wordpress/htdocs/"
#Alias /wordpress "/opt/bitnami/apps/wordpress/htdocs"

RewriteEngine On
#RewriteCond "%{HTTP_HOST}" ^ec2-([0-9]{1,3})-([0-9]{1,3})-([0-9]{1,3})-([0-9]{1,3})\..*\.amazonaws.com(:[0-9]*)?$
#RewriteRule "^/?(.*)" "%{REQUEST_SCHEME}://%1.%2.%3.%4%5/$1" [L,R=302,NE]

#RewriteCond %{HTTPS} !=on
#RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]

RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf"

Video Tutorial: https://www.youtube.com/watch?v=WQwvwiPZlZE




- Spring Development Environment
Slack Discussion Repositories https://github.com/terawarehouse/terawarehouse-cataloghttps://github.com/terawarehouse/terawarehouse-reactBefore we can begin coding, we must first download and configure Spring Tools 4, which is the latest available Spring...

- Wordpress Directory And File Permission
The issue of setting the correct permission hits me every time I install Wordpress. So I've created a script that will set its content to the correct permission. Below is part of the script: // Make sure that the proper owner is set since I'm...

- How To Handle An Xmlrcp Wordpress Attack On Nginx Server
I'm not really a system administrator and these steps are just based on my personal experience in securing our own wordpress websites. Lately there has been a lot of attacks on wordpress sites (since it's a popular framework) specially on windows...

- How To Setup A Subdomain In Your Nginx Server
Lately I've created a sub-domain for one of my website. I hope you follow this blog on how to setup your nginx wordpress site. In the same server where I host my maindomain.com, I've added a subdomain.maindomain.com. And here is how: I created...

- How To Migrate Your Godaddy Web Hosting To Digitalocean
Lately I've been reading some good articles about DigitalOcean as a cheap VPS option in online hosting and so I decided to try and subscribe to one. Since my wordpress website hosting is already expiring I decided to moved the hosting to DigitalOcean...



Tech-Today








.