Blynk Network Port Forward Config
Port forwarding & proxy config for Blynk Server
I’m using blynk server (local) to monitor the state-of-charge of a battery that’s connected to a solar panel.
To get the app working from inside the local network and outside when I’m travelling, we need to configure DNS and port forwarding as follows.
Note 1:
- the admin pages are accessed over https on port 443
- the app uses a proprietary protocol (not http) also on port 443…!
Note 2:
- please decide for yourself whether exposing this service to the internet is a good thing…? Perhaps you prefer a VPN solution, then your device can simply access internal services when connected.
Tools
- DNS external and internal (dnsmasq on docker)
- router — internet connection, port forwarding
- nginx (docker) — proxy traffic to the blynk server
- Blynk Server (local, docker) — note, local server is now deprecated. Blynk.io decided to discontinue the product.
- apache — I was not able to get apache to proxy the stream
External DNS
- blynk.home.com => 123.123.123.123 (my external ip address)
Internal DNS
- blynk.home.com => 10.0.0.25 (internal ip of server on vm/docker)
- nginx.home.com => 10.0.0.24 (internal ip of nginx)
Router port forwarding
- 8080 => blynk.home.com:80 (optional, if you want devices in the wild)
- 8444 => nginx.home.com:8444 (stream, for the app)
- 8443 => nginx.home.com:8443 (https, for admin pages)
nginx config
Forward both 8444 (blynk proto) and 8443 (https) to the Blynk server
events {}stream {
upstream blynkserver {
server 10.0.0.25:443;
}
server {
listen 8444;
proxy_pass blynkserver;
}
}http {
server {
# Server configuration
listen 80 default_server;
return 301 https://$host$request_uri;
} server {
server_name blynk.home.com;
listen 8443;
ssl on;
ssl_certificate ssl/blynk.home.com.cert.pem;
ssl_certificate_key ssl/blynk.home.com.privkey.pem;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
location / {
proxy_ssl_verify off;
proxy_pass https://10.0.0.25:443/;
}
}
}
Blynk.App config
At the login add
- custom domain blynk.home.com
- port 8444
The app should now work on local wifi and on 4G.
Access the admin screens on https://blynk.home.com:8443/admin
Happy blynking..!
Alternative (simpler) solution
Although the solution above is somewhat complex, it allows me to use the same domain+port for internal and external purposes.
If you simply want to access your blynk server from the internet, just forward homeip:8443 to 10.0.0.25:443 — but you already knew that… ;)