Info Security Memo
  • Blog
  • Sitemap
    • Categories
  • Contact
  • About
  • Resources
  • Tools
  • 51sec.org

Build Confidence

Focusing on Information Security 

Info Security Notes

Switching From Ezoic Hosting to My Own Hosting Arm64 based Ubuntu 20.04

10/2/2021

0 Comments

 
Switching From Ezoic Hosting to My Own Hosting Arm64 based Ubuntu 20.04

 Ezoic DNS and Hosting screwed up my site this morning. All of my root doman's A records are gone and even I added them back in, they are still not working. I am believing some of DNS configuration must be wrong in their backend. Support is not that much helping since it is out of their technical ability. 

Fortunately I have a back up site created on my Oracle Cloud Arm64 machine. This post is to record all steps I did to switch from Ezoic hosting to my own hosting.



Make sure my backup wordpress site is up on one of my subdomain

All of my Nginx, Wordpress and DB dockers deployed by Portainer based on my previous post:


Nginx configuration changed to add two websites in:

oot@4ccb3643b7e4:/# cat /etc/nginx/conf.d/wp.conf 
server {
    listen       80;
    server_name  opc2armwp.51sec.eu.org 51sec.org www.51sec.org;

location / {
    proxy_pass       http://mywp_wordpress_1;
    proxy_http_version         1.1;
    proxy_read_timeout 300;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Real-PORT $remote_port;
           }

}


Install All-in-One WP Migration Plug-ins    

Since I have backup file from All-In-One WP Migration plug-in, I will have to install following two plug-ins to restore my backup:
  • All-in-one wp migration
  • All-in-one wp migration unlimited extension or All-in-one wp migration file extension (512M limitation)

Import the backup file into your wordpress site.






Wordpress configuration file change - wp-config.php


Once you imported the backup file, the WordPress Address and Site Address will be different for your site, www.51sec.org. I will need to modify wp-config.php file to make it changed. Following two lines will need to be added into wp-config.php file:
  • define('WP_HOME','https://www.51sec.org');
  • define('WP_SITEURL','https://www.51sec.org');


root@ddcb07417c01:/var/www/html# more wp-config.php
<?php
/**
 * The base configuration for WordPress
 *
 * The wp-config.php creation script uses this file during the installation.
 * You don't have to use the web site, you can copy this file to "wp-config.php"
 * and fill in the values.
 *
 * This file contains the following configurations:
 *
 * * MySQL settings
 * * Secret keys
 * * Database table prefix
 * * ABSPATH
 *
 * This has been slightly modified (to read environment variables) for use in Docker.
 *
 * @link https://wordpress.org/support/article/editing-wp-config-php/
 *
 * @package WordPress
 */

// IMPORTANT: this file needs to stay in-sync with https://github.com/WordPress/WordPress/blob/master/wp-config-sample.php
// (it gets parsed by the upstream wizard in https://github.com/WordPress/WordPress/blob/f27cb65e1ef25d11b535695a660e7282b98eb742/wp-admin/setup-config.php#L356-L392)

// a helper function to lookup "env_FILE", "env", then fallback
if (!function_exists('getenv_docker')) {
        // https://github.com/docker-library/wordpress/issues/588 (WP-CLI will load this file 2x)
        function getenv_docker($env, $default) {
                if ($fileEnv = getenv($env . '_FILE')) {
                        return rtrim(file_get_contents($fileEnv), "\r\n");
                }
                else if (($val = getenv($env)) !== false) {
                        return $val;
                }
                else {
                        return $default;
                }
        }
}


define('WP_HOME','https://www.51sec.org');
define('WP_SITEURL','https://www.51sec.org');





Now from wordpress admin portal, you will find out those two URL settings have been locked down.






Cloudflare configuration

Add dns A record to point to my OCP's Arm64 machine's public IP. Remove all other Ezoic hosting's A records. 

Make sure SSL/TLS encryption mode is full. Else, my photos URL which is using photo.51sec.org subdomain will fail to load. It will show an error to say there are too many redirections.



Install Certbot

Since my Arm64 machine is using Ubuntu20.04, here are two commands to install CertBot:
  • apt install certbot
  • apt install python3-certbot-nginx

You will need both. Second command is to install Nginx plugin for Certbot.

Using following command to apply ssl cert for website www.51sec.org:

  • certbot --nginx

After the step done, here is your wp.conf Nginx configuration looks like:


root@4ccb3643b7e4:/# cat /etc/nginx/conf.d/wp.conf 
server {
    listen       80;
    server_name  opc2armwp.51sec.eu.org 51sec.org www.51sec.org;

location / {
    proxy_pass       http://mywp_wordpress_1;
    proxy_http_version         1.1;
    proxy_read_timeout 300;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Real-PORT $remote_port;
           }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/www.51sec.org/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/www.51sec.org/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
root@4ccb3643b7e4:/# 



References
































via Blogger http://blog.51sec.org/2021/10/switching-from-ezoic-hosting-to-my-own.html
October 02, 2021 at 05:35PM Blog
0 Comments



Leave a Reply.

    Categories

    All
    Architecture
    Blog
    Checkpoint
    Cisco
    Cloud
    CyberArk
    F5
    Fortigate
    Guardium
    Juniper
    Linux
    Network
    Others
    Palo Alto
    Qualys
    Raspberry Pi
    Security
    SIEM
    Software
    Vmware
    VPN
    Wireless

    Archives

    March 2024
    February 2024
    January 2024
    December 2023
    November 2023
    October 2023
    September 2023
    August 2023
    July 2023
    June 2023
    May 2023
    April 2023
    March 2023
    February 2023
    January 2023
    December 2022
    November 2022
    October 2022
    September 2022
    August 2022
    July 2022
    June 2022
    May 2022
    April 2022
    March 2022
    February 2022
    January 2022
    December 2021
    November 2021
    October 2021
    September 2021
    August 2021
    July 2021
    June 2021
    May 2021
    April 2021
    March 2021
    February 2021
    January 2021
    December 2020
    November 2020
    October 2020
    September 2020
    August 2020
    July 2020
    October 2019
    September 2019
    June 2019
    July 2018
    May 2018
    December 2017
    August 2017
    April 2017
    March 2017
    January 2017
    December 2016
    November 2016
    October 2016
    September 2016
    August 2016
    July 2016
    June 2016
    May 2016
    April 2016
    March 2016
    February 2016
    January 2016
    December 2015
    November 2015
    October 2015
    September 2015
    August 2015
    July 2015
    June 2015
    May 2015
    April 2015
    March 2015

    Print Page:

    RSS Feed

    Email Subscribe
Powered by Create your own unique website with customizable templates.
  • Blog
  • Sitemap
    • Categories
  • Contact
  • About
  • Resources
  • Tools
  • 51sec.org