How to redirect toxic websites to your personal blog in the most procrastinating and overengineering way you could possibly think of.

Create your personal website or add some redirect script

mkdir ~/blog && cd ~/blog
echo "<html>
  <body>
    Some harsh, yet inspiring quote
  </body>
<html>" > index.html
# or create simple redirect script to more productive website
echo "<html>
  <head>
    <script>
      location.href = 'https://jasiek.net'
    </script>
  </head>
</html>" > index.html

Install and run local server (check http://127.0.0.1 to verify if it works)

npm install -g browser-sync
cd ~/blog
sudo browser-sync start --server --port 80

Generate SSL certificate (for https://localhost):

brew install openssl
mkdir ~/certs && cd ~/certs
openssl genrsa -out jasiek.key 2048
openssl req -x509 -new -nodes -key jasiek.key -sha256 -days 1825 -out jasiek.pem
sudo security add-trusted-cert -d -r trustRoot -k "/Library/Keychains/System.keychain" ~/certs/jasiek.pem

Check if server works via HTTPS

cd ~/blog
sudo browser-sync start --server --port 443 --https.key ~/certs/jasiek.key --https.cert ~/certs/jasiek.pem

Install and configure pm2 to run your server on reboot

npm install pm2 -g
cd ~/blog
sudo pm2 start "sudo browser-sync start --server --port 443 --https.key ~/certs/jasiek.key --https.cert ~/certs/jasiek.pem"
pm2 startup

Redirect all toxic websites for a better future!

sudo echo "
127.0.0.1 instagram.com
127.0.0.1 www.instagram.com

127.0.0.1 facebook.com
127.0.0.1 www.facebook.com" >> /etc/hosts

Sometimes you need empty cache and hard reload toxic domains

  • open developer tools panel (cmd + shift + i)
  • click and hold reload icon / right click reload icon
  • a menu will open
  • choose 3rd option ("Empty cache and hard reload")

If Chrome still block https://localhost:

  • write thisisunsafe while on the site
  • or allow insecure localhost: chrome://flags/#allow-insecure-localhost
  • or go to chrome://net-internals/#hsts under Delete domain security policies, write your toxic website domain and press Delete (it will remove HSTS header)

VoilĂ ! You just wasted a few hours trying to be more productive!