Build Your Homelab: 24 – ntfy From Outside Your Home Network

Homelab 23 - ntfy

Now that we have our own ntfy server up and running that can send notifications to our phone, we probably need to get those notifications when we are not at home as well. This will take a bit of configuration on more than just the ntfy installation, but it will definitely be worth it. Yes, we can just use a VPN server as well, but we have not covered setting up a universal VPN regardless of hardware used. So for today, we are going to set up our ntfy notifications to be receivable from outside of our home network.


Step 1: Reverse Proxy with NGINX.

First we will need to set up our incoming connections currently being handled by nginx. Please ensure to have the following steps set up already:
Setting up and nginx VM
Nginx from outside your home network

Once that is set up, we can forward our service to ntfyinstead of WordPress. After logging in to your Proxmox instance, in the left navigation window, expand Datacenter, then expand the Proxmox node running our Nginx VM. In the middle navigation pane, select Proxmox Console Buttonto open the integrated console. First we need to navigate to the directory where config files are stored:

cd /etc/nginx/sites-available

Once there, we can create a new config file. Let’s call the config file ntfy So use the command:

nano ntfy

We need to add the entire configuration file in the file, please take note of the indentation as it needs to be the same:

server {
listen 80;
server_name techdecode.tplinkdns.com;
location / {
proxy_pass http://192.168.2.34;
proxy_http_version 1.1;
proxy_buffering off;
proxy_request_buffering off;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 3m;
proxy_send_timeout 3m;
proxy_read_timeout 3m;
client_max_body_size 0;
}
}

Please substitute the server name techdecode.tplindns.com with your own Dynamic DNS name, and substiture the IP address 192.168.1.34 with the IP address that your ntfy server is running on. Once added, save with Ctrl+S and exit with Ctrl+X. We now just need to create the “shortcut” again, so run the command:

ln -s /etc/nginx/sites-available/ntfy /etc/nginx/sites-enabled/

Once the link has been created, we can test the configuration first by running the command

nginx -t

If everything succeeds, we can update the configuration by running:

systemctl reload nginx

This means that the new config is live and we can change the setup of our phone receiving the notifications


Step 2: Update notification endpoint on receiving device

Back on our phone, all we need to do is open the ntfy app and go to settings again. This time, in stead of changing the default server to our LAN IP address, we are going to use the Dynamic DNS endpoint. Once that is done, we can subscribe to the same topic as we did before and we should see all of the messages coming in as usual.


Conclusion

We can now receive messages when we are not on our home network, and we also don’t need a VPN connection to be able to receive messages. This is due to us using a Dynamin DNS service in conjunction with a reverse proxy, in our case NGINX. The only problem is that this connection is now open to the entire internet, we should probably get it a wee bit more secured. So let’s look at that in our next installment.