Word Count: 1072
  • Post category:Servers
  • Post last modified:2024-07-05

Introduction

This articles describes the process of buying the domain name “tfwtech.com” and use it to replace the existing DN “innovriver.com” on MJ1900.

Buy DN at Porkbun

  • PorkBun appears to be the cheapest DNS registrar in the market.
  • Purchased the DN “tfwtech.com” for 2 years at USD$17.36. The current DN will expire on 2026-03-29. Renewal price is USD$10.37 per year including WHOIS privacy protection.
  • Pointed the A records tfwtech.com and www.tech.com to the MJ1900 WAN address.
  • Generated the API Key and Secret Key for use in the DDNS updater.

Develop and Test the Dynamic DNS Updater

  • The updater script is located at MJ1900:/doc/scripts/updater-porkbun-ddns.sh
  • The current public IP is obtained from http://api.ipify.org
  • The cached DNS IP ($DnsIP) is obtained by using the Porkbun API
  • The Public and DNS IPs are compared. If they are different, the followng DNs will be updated with the value in Public IP:
    • Subdomain “www”.
    • Wildcard “/*”
    • Main domain “tfwtech.com”
  • Comparison results are logged in the journald log system.
  • The APIs are obained from the github “OpenWRT Dynamic DNS”. See Reference section.
  • The script was tested successfully by changing the domain and subdomain IP to arbitrary values in the Registrar and then updated to the correct IPs by the script.
  • To run the script:
    • # /doc/scripts/updater-porkbun-ddns.sh
  • Cron job is set up to run the script at 20 min of every hours.
  • To view the system log, for example since 16:00 hour:
    • # journalctl --since 16:00 -t tfwIpUpdate

Set virtual host and SSL cert for tfwtech.com

  • Created the virtual host in /etc/apache2/sites-available/001-tfwtech-default.conf
  • Used certbot to create the SSL certifcate for the above host, which also created the virtual host file for SSL access.
    • # certbot --apache --key-type rsa
      • Type RSA is required for using the same cert in the QNAP NAS (SilverRiver)
    • The command displayed a list of domains for selection to get the SSL certificates.

Websites

  1. (WP) innovriver.com/fai-room ==> tfwtech.com/fai-room
    • WP setting -> general, and updated the WordPress Address (URL) and Site Address (URL).
  2. lets-share.innovriver.com ==> lets-share.tfwtech.com
    • disable lets-shares
      • a2dissite lets-share
      • a2dissite lets-share-le-ssl
      • systemctl reload apache2
    • copy original VH files to lets-share-tt.conf (tt for tfwtech)
      • cp lets-share.conf lets-share-tt.conf
      • edit the ServerName
      • remove the Rewrite Conditions and Rules at the file bottom
    • Enable the site and create SSL cert.
      • a2ensite lets-share-tt
      • systemctl reload apache2
      • In Porkbun, add a A record to point the subdomain to the public IP
      • certbot --apache -v
      • Select the doman for SSL cert.
      • Certbot will add rewrite rules and create the VH file for SSL access
    • The site was down with errors:
      • This page isn’t working / lets-share.tfwtech.com didn’t send any data. ERR_EMPTY_RESPONSE
      • Added A records for lets-share.tfwtech.com and *.tfwtech.com apparently solved the connection problem.
      • The browser connected to the site but got TypeError: Failed to fetch data. To solve this problem, the API URLs had to be changed to point to the new domain name. See below.
    • Modify lets-share app for the new domain name:
      • backed up existing site to /app/www/lets-share/_backup-ver2.0.0
      • Located the source code (DT16: …/Documents/ProjVue3/lets-share, and make sure the version was same as that on the web server.
      • Deleted the dist directory.
      • Searched and replaced version number to 2.1.0 (package.json and AboutView.vue)
      • Searched and replaced the @Copyright year (App.vue)
      • Searched and replaceed the domain names in all files of the app (useFetchApiData.js, SharerStore.js, SnookerRateStore.js)
      • Rebuilt the app according to the “Productin Build procedures” section in My_setup-Ph2.txt.
      • Moved the “dist” directory to the web server.
      • Don’t touch the api directory on the web server. No changes were required in this directroy.
      • On the MJ1900:/app/www, run # www-chxy.sh lets-share to modify the ownership and permissions.
  3. (WP) test.innovriver.com ==> test.tfwtech.com
    • copy original VH files to test-tt.conf (tt for tfwtech)
      • cp test.conf test-tt.conf
      • edit the ServerName
      • remove the Rewrite Conditions and Rules at the file bottom
    • Enable the site and create SSL cert.
      • a2ensite test-tt
      • systemctl reload apache2
      • certbot --apache -v
      • Select the doman for SSL cert.
      • Certbot will add rewrite rules and create the VH file for SSL access
    • Log into WP Dashboard and update both WordPress Address and Site Address to https://test.tfwtech.com
    • disable test.innovriver.com
      • a2dissite test
      • a2dissite test-le-ssl
      • systemctl reload apache2
  4. (WP) test-astra.innovriver.com ==> test-astra.tfwtech.com
    • copy original VH files to test-astra-tt.conf (tt for tfwtech)
      • cp test-astra.conf test-astra-tt.conf
      • edit the ServerName
      • remove the Rewrite Conditions and Rules at the file bottom
    • Enable the site and create SSL cert.
      • a2ensite test-astra-tt
      • systemctl reload apache2
      • certbot --apache -v
      • Select the doman for SSL cert.
      • Certbot will add rewrite rules and create the VH file for SSL access
    • Log into WP Dashboard and update both WordPress Address and Site Address to https://test-astra.tfwtech.com
    • disable test-astra.innovriver.com
      • a2dissite test-astra
      • a2dissite test-astra-le-ssl
      • systemctl reload apache2
  5. innovriver.com/tfw-htaccess ==> tfwtech.com/tfw-htaccess
    • Search and replace the domain name in the website (index.php)
  6. tfw-test.innovriver.com ==> tfw-test.tfwtech.com
    • copy original VH files to test-astra-tt.conf (tt for tfwtech)
      • cp tfw-test.conf tfw-test-tt.conf
      • edit the ServerName
      • remove the Rewrite Conditions and Rules at the file bottom
    • Enable the site and create SSL cert.
      • a2ensite tfw-test-tt
      • systemctl reload apache2
      • certbot --apache -v
      • Select the doman for SSL cert.
      • Certbot will add rewrite rules and create the VH file for SSL access
    • Search and update the domain names in all files on this website.
    • disable test-astra.innovriver.com
      • a2dissite tfw-test
      • a2dissite tfw-test-le-ssl
      • systemctl reload apache2

Reconfigure OpenVPN

Details of the OpenVPN set up on MJ can be found in here.

  • Edit the client base.conf
    • # nano /etc/openvpn/innovr-client-configs/base.conf
    • update the remote directive to remote tfwtech.com 1194
  • Geneate new vpn clients
    • # /etc/openvpn/ivr-add-client.sh client_cn
    • The client_cn are:
      • tt-tfwph-m13,
      • tt-tfwnb-t590,
      • tt-tfwnb-720s,
      • tt-sypph-m13p
    • The generated .ovpn files are placed in /etc/openvpn/innovr-client-configs/files directory. Download these ovpn files to the concerned devices.
  • Revoke unused clients
    • # /etc/openvpn/ivr-remove-client.sh client_cn

To-do list after existing DN is expired

  • Remove unused Apache virtual hosts by end April 2024
  • Revoke unused VPN clients by end April 2024

Reference