How to Enable Wordpress HTTPS on AWS
This tutorial will help us install Wordpress on Amazon using a Wordpress image provided by Bitnami. We will also enable HTTPS by using an Am...
https://www.czetsuyatech.com/2018/07/wordpress-enable-https-on-aws.html
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
The final version of the file should look like below. Take note of the commented lines, those are the originals.
Video Tutorial: https://www.youtube.com/watch?v=WQwvwiPZlZE
Steps
- Create an EC2 instance and install this Wordpress image from Bitnami: https://aws.amazon.com/marketplace/pp/B00NN8Y43U.
- Install Easy Https Redirection plugin on Wordpress - https://wordpress.org/plugins/https-redirection/
- 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';
- 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.
- 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]
- 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
Post a Comment