Monitor your PiVPN connections with a simple static HTML page
This script allows you to easily monitor your PiVPN connections by visiting a static web page, which is easier than SSHing into a machine to view clients.
NOTE: This is NOT a GUI for PiVPN. This is purely a static HTML page for viewing connected clients. You will NOT be able to create, modify, disable, or delete any VPN profiles. That still must be done through the host machine.
- PiVPN - see https://www.pivpn.io/ for more info
- Web Server of your choice - There are many options avaliable, i.e. NGINX, Apache, Lighttpd, php built in server. Anything is fine.
- (Optional) figlet - For a nice banner at the top of your page. can be installed with:
sudo apt install figlet
- Move to your directory of choice, clone the repo, and cd into it or download the
generate
file.
git clone https://github.com/SlimJim716/PiVPN-Static-Status
cd PiVPN-Static-Status
- Open
generate
with an editor of your choice, likenano
, orvim
.
nano generate
- Edit the
CONFIG AREA
section to match your installation. Save the file and exit when done
#-------------------------------------------------------
# CONFIG AREA
#-------------------------------------------------------
wg_enabled=true #set to true if you have Wireguard enabled in PiVPN, set to false otherwise
ovpn_enabled=true #set to true if you have OpenVPN enabled in PiVPN, set to false otherwise
banner_name="PiVPN Status" #(OPTIONAL) change the name of the top ascii banner. Requires figlet.
#-------------------------------------------------------
#-------------------------------------------------------
- Make
generate
executable
chmod 744 generate
- Open crontab
crontab -e
- Add the following line to cron so the script will update periodically. This will refresh the HTML every minute - change the timing as desired. Be sure to change the placeholder paths below.
* * * * * /path/to/script/generate > /path/to/output/index.html
6a. Optional. Since this is most likely deployed on a Raspberry Pi, instead of writing to disk, we can write to a tmpfs partition instead to minimize disk usage. We can change the line above to this.
* * * * * mkdir -p /dev/shm/pivpnss && /path/to/script/generate > /dev/shm/pivpnss/index.html
- Serve the page with your favorite web server. This step is up to you. Below is a basic config example for NGINX using a subdomain for the page.
server {
listen 80;
server_name pivpnstatus.example.com;
location / {
root /path/to/PiVPN-Static-Status;
}
}
You could also use PHP's built in web server while inside the PiVPN-Static-Status directory.
php -S <YOURIP>:8080 index.html