• Obtain SSL Certificate
  • Configure HAProxy
  • Configure MySQL
  • Run Docker Container
# Simple WordPress with nothing
docker run --privileged --name kimconnect-p XXXXX:XX -d wordpress
  • Configure WordPress Container with SSL
# Install VIM to edit .htaccess
docker exec -it blog /bin/bash
apt-get update && apt-get install neovim -y
vim .htaccess #edit the file to finish with content below
 
# Setup WordPress to run on HTTPS
# Preemptively resolve looping redirects and mixed-contents (http & https) issues with browsers raising security warnings
vim wp-config.php
#### Add these lines at the top, right below <?php ####
define('FORCE_SSL_ADMIN', true);
define('FORCE_SSL_LOGIN', true);
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') $_SERVER['HTTPS']='on';
 
  • Run WordPress Setup
Troubleshooting:
 
Error: Sorry, you are not allowed to access this page.
Resolution: 
Method 0: Ensure that SSL_ADMIN is set correctly (at the top of wp-config.php)
 
Method 1: Edit user role
UPDATE wp_usermeta SET meta_value='a:1:{s:13:"administrator";s:1:"1";}' WHERE user_id=1 AND meta_key='wp_capabilities';
 
Method 2: Create New Admin User
INSERT INTO kimconnect.wp_users ('ID', 'user_login', 'user_pass', 'user_nicename', 'user_email', 'user_url', 'user_registered', 'user_activation_key', 'user_status', 'display_name') VALUES ('2', 'kim', MD5('test'), 'Kim Connect', '[email protected]', 'https://www.kimconnect.com/', '2019-01-01 00:00:00', '', '0', 'Kim Doan');
INSERT INTO 'kimconnect'.'wp_usermeta' ('umeta_id', 'user_id', 'meta_key', 'meta_value') VALUES (NULL, '2', 'kc_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO 'kimconnect'.'wp_usermeta' ('umeta_id', 'user_id', 'meta_key', 'meta_value') VALUES (NULL, '2', 'kc_user_level', '10');
 
# Manually Update Admin user’s password using MySQL commands
UPDATE kimconnect.wp_users SET user_pass = MD5('PASSWORD') WHERE ID = 1;
 
# Show permissions as octal values
root@CONTAINER_ID:/var/www/html# stat -c "%a %n" *
644 index.php
644 license.txt
644 readme.html
644 wp-activate.php
755 wp-admin
644 wp-blog-header.php
644 wp-comments-post.php
644 wp-config-sample.php
666 wp-config.php
755 wp-content
644 wp-cron.php
755 wp-includes
644 wp-links-opml.php
644 wp-load.php
644 wp-login.php
644 wp-mail.php
644 wp-settings.php
644 wp-signup.php
644 wp-trackback.php
644 xmlrpc.php
 
# Database manipulation
UPDATE
    kimconnect.wp_usermeta
SET
    use_ssl = 1,
WHERE
    user_id = 1;
 
# Delete all tables in database
USE kimconnect;
SET FOREIGN_KEY_CHECKS = 0;
SET GROUP_CONCAT_MAX_LEN=32768;
SET @tables = NULL;
SELECT GROUP_CONCAT('`', table_name, '`') INTO @tables
  FROM information_schema.tables
  WHERE table_schema = (SELECT DATABASE());
SELECT IFNULL(@tables,'dummy') INTO @tables;
 
SET @tables = CONCAT('DROP TABLE IF EXISTS ', @tables);
PREPARE stmt FROM @tables;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET FOREIGN_KEY_CHECKS = 1;