Home · Blog · Projects


Local Ip Adresses

add .local domains in your local wifi network.

Install

(for linux lubuntu)

shSize: 75 Bytes
sudo apt update
sudo apt install avahi-utils libnss-mdns avahi-daemon nginx

nginx

shSize: 47 Bytes
sudo nano /etc/nginx/sites-available/local-apps

nginx.conf content
nginxSize: 997 Bytes
server {
    listen 80;
    server_name grafana.local;

    location / {
        proxy_pass http://127.0.0.1:3000;

        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

server {
    listen 80;
    server_name homeassistant.local;

    location / {
        proxy_pass http://127.0.0.1:8123;

        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

server {
    listen 80;
    server_name app.local;

    location / {
        proxy_pass http://127.0.0.1:8080;

        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Remove the nginx standard Page:

shSize: 43 Bytes
sudo rm -f /etc/nginx/sites-enabled/default

Reload

Reload the nginx server

shSize: 13 Bytes
sudo nginx -t
shSize: 27 Bytes
sudo systemctl reload nginx

Avahi

shSize: 38 Bytes
sudo nano /etc/avahi/avahi-daemon.conf

change this line to wlo1 in the avahi daemon config

iniSize: 21 Bytes
allow-interfaces=wlo1

Start

shSize: 98 Bytes
sudo systemctl enable avahi-daemon
sudo systemctl start avahi-daemon
systemctl status avahi-daemon
shSize: 35 Bytes
sudo systemctl restart avahi-daemon
shSize: 49 Bytes
avahi-publish -a -R grafana.local 192.168.178.103

Test

shSize: 30 Bytes
avahi-resolve -n grafana.local

Make Forever

shSize: 50 Bytes
sudo nano /etc/systemd/system/mdns-grafana.service
shSize: 46 Bytes
sudo nano /etc/systemd/system/mdns-app.service
shSize: 56 Bytes
sudo nano /etc/systemd/system/mdns-homeassistant.service

mdns-grafana.service
iniSize: 245 Bytes
[Unit]
Description=mDNS alias for Grafana
After=avahi-daemon.service
Requires=avahi-daemon.service

[Service]
ExecStart=/usr/bin/avahi-publish -a -R grafana.local 192.168.178.103
Restart=always
RestartSec=2

[Install]
WantedBy=multi-user.target

mdns-app.service
iniSize: 237 Bytes
[Unit]
Description=mDNS alias for app
After=avahi-daemon.service
Requires=avahi-daemon.service

[Service]
ExecStart=/usr/bin/avahi-publish -a -R app.local 192.168.178.103
Restart=always
RestartSec=2

[Install]
WantedBy=multi-user.target

mdns-homeassistant.service
iniSize: 257 Bytes
[Unit]
Description=mDNS alias for homeassistant
After=avahi-daemon.service
Requires=avahi-daemon.service

[Service]
ExecStart=/usr/bin/avahi-publish -a -R homeassistant.local 192.168.178.103
Restart=always
RestartSec=2

[Install]
WantedBy=multi-user.target

Make Active

shSize: 178 Bytes
sudo systemctl daemon-reload

sudo systemctl enable --now mdns-grafana.service
sudo systemctl enable --now mdns-app.service
sudo systemctl enable --now mdns-homeassistant.service

Test

shSize: 69 Bytes
systemctl status mdns-grafana.service

avahi-resolve -n grafana.local

Please creadit if repost this or use it.