sudo apt update && sudo apt -y upgrade
sudo ufw allow 1022/tcp
sudo do-release-upgrade (add -d for development version)
sudo ufw delete 2, 4
Documenting my journey experiencing new technologies and life
sudo apt update && sudo apt -y upgrade
sudo ufw allow 1022/tcp
sudo do-release-upgrade (add -d for development version)
sudo ufw delete 2, 4
for ubuntu… i needed to
sudo chmod g+r /var/lib/boinc/gui_rpc_auth.cfg
as well as sudo usermod -a -G boinc $USER
optional step, if you’re using a boinc account manager, the syntax for sending the password is single quotes if you have a complex password. it took me many hours to figure this out.
boinccmd --join_acct_mgr bam.boincstats.com actng 'Passw0rd!!!'
(change your username from actng to your username. no, Passw0rd!!! isn’t my password but yes that is considered complex enough to warranty single quotes around or it won’t work.)
after waiting you can try boinccmd --get_tasks to check if tasks are downloaded/uninitialized or executing
Google launched something called Cloud NAT Gateway that charges for bandwidth to do NAT. It makes it more expensive to run than going with external IP (at least in the low volumes that I do). I found this blog entry by Yuvraaj at Crave.io that allows you to enable NAT in a few steps. I’ve documented the commands below so I can refer to them in the future if I need them and in case the crave.io blog entry is no longer available or I can’t find it for some reason.
Create or edit this file/script that runs everytime the machine is booted
/etc/rc.local
#!/bin/bash
set -x
# Turn on IP forwarding
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
# Turn on the route
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
Setup Route in GCP Routing table
gcloud compute routes create no-ip-internet-route --network default --destination-range 0.0.0.0/0 --next-hop-instance nat-gateway --next-hop-instance-zone us-west1-b --tags no-ip --priority 800
Setup networking tags for VMs that need this
gcloud compute instances add-tags <existing-instance> --tags no-ip
Thanks to Karson for this one.
Create a file:
sudo nano ./run.sh
#!/bin/sh
if ps -ef | grep -v grep | grep boinc ; then
exit 1
else
sudo systemctl restart boinc-client &
exit 0
fi
Change permissions
sudo chmod +x ./run.sh
Make it run automatically
crontab -e
Every second
* * * * * /home/user/run.sh
Wrote a quick script to make a copy of files + db
#!/bin/bash
cd /srv/www/wordpress
tar -zcvf ~/backup-$(date +"%Y%m%d").tar.gz *
cd
ls backup-*
sudo mysqldump -u root --password="<insert password>" wordpress > ./mysql-$(date +"%Y%m%d").backup
ls mysql-*
The WordPress healthcheck was complaining about REST API and curl error 7. I narrowed it down to a SSL problem based on the error msgs complaining about no response on port 443. Weird as I didn’t have this problem yesterday.
Despite setting up my DNS with cloudflare and having traffic proxied under their SSL tunnel, it is not a true SSL connection. I figured this out when I “curl https://localhost” or “curl https://adrianng.com” and it said connection refused. (The cloudflare proxy only encrypts the traffic between the client’s browser and cloudflare’s server. The traffic between cloudflare and my web server was still unencrypted.)
I ended up using cerbot / letsencrypt to install a SSL certificate on this web server:
sudo snap install core; sudo snap refresh core
sudo snap install –classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot –apache
This successfully setup a certificate on the server and the site was SSL enabled. “curl https://adrianng.com” proved this as now I get a proper response. However on the web browser, I was getting too many redirects.
To fix this, I went into my cloudflare dashboard, SSL/TLS and found this screen:

Changing it from Flexible to Full (or even Full strict) made it work again.
Continuing from the previous post about migrating this site to an Azure VM… I noticed the the site’s performance was horrendous on the free B1s VM size 1CPU 1GB.
I increased the VM size to B1MS 1CPU 2GB which takes me out of the free tier but so far it seems to work. But in the interest of going back to free tier, I’m going to want to go back to the 1GB VM size. I’ll need to look into this some more.
So it turns out the Azure Ubuntu VM by default doesn’t have a swap file. This appears to be the reason why the VM bogs down and runs out of memory. I checked the site this morning and it wasn’t responsive at all. Azure portal showed it had 35Mb of RAM free.
So I just created a swap file and rebooted. Let’s see if this works. So far so good.
Create 2GB file in root directory called swapfile:
sudo dd if=/dev/zero of=/swapfile bs=1M count=2048 status=progress
Give only system permission:
sudo chmod 600 /swapfile
Make it a swap file:
sudo mkswap /swapfile
Turn on swap file:
sudo swapon /swapfile
Make persistent by editing /etc/fstab and adding swapfile entry:
sudo nano /etc/fstab
“/swapfile none swap 0 0”
Reboot:
sudo reboot