Set up a Pi web server!

Install ngrok

From the ngrok download page, download the Linux ARM package to your RPi, unzip it, and move the executable to a convenient place (/bin or something like that. Hint: the following commands may be a helpful template:

cd ~
wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip

Make the ngrok config file

In your home directory, make the directory .ngrok2 and the file ngrok.yml. In that file, type the following:

tunnels:
 websrv:
  proto: http
  addr: 80

The word "websrv" in this and following instructions may be replaced with your own custom site name. This name is shown only to you, not to site viewers.

Set up msmtp for sending email

Instructions to come... If you are doing show-pi-ip already, this is unnecessary because you already have it.

Make the ngrok display info script

Create the file show-url-script and make it executable. I put mine in /etc/init.d because I had similar scripts there. In the file, type the following:

#!/bin/bash

ngrokurl=''
until [ -n "$ngrokurl" ]; do
    ngrokurl=$(curl -s http://localhost:4040/api/tunnels | grep -ioE "http://\w*?\.ngrok\.io")
    sleep 1
done

currdate=$(date '+%D %H:%M:%S')
printf "Subject: Pi URL\nTo: arigert1@gmail.com\n\n%s\n Raspberry Pi Hostname, $currdate: $ngrokurl" | msmtp -t israelterrill@gmail.com

Make ngrok start automatically

Edit /etc/rc.local and add the following just before the "exit 0" line:

# start ngrok
/bin/ngrok start websrv --config=/home/aisha/.ngrok2/ngrok.yml --log=stdout > /home/aisha/ngrok.log &
sudo /etc/init.d/show-url-script

Reboot and test

sudo reboot and see whether it works. If not, check that you have customized all the things you had to type with your own information (replace "aisha" with your user name, my email address with yours, etc.) Also, of course, you have to have apache installed and running for the web server to work.