Sign inSign up

ffin/meshviewer

By ffin

•Updated 24 days ago

Meshviewer is an app to represent nodes and links on a map for Freifunk open mesh network.

Image
0

2.7K

ffin/meshviewer repository overview

mkdir meshviewer
wget https://raw.githubusercontent.com/freifunk/meshviewer/main/config.example.json -O meschviewer/config.json

docker-compose.yml

version: "3"

services:
  meshviewer:
    # download latest meshviewer release and run it in nginx
    # requires meshviewer.json file created by yanic
    container_name: meshviewer
    image: ffin/meshviewer
    restart: always
    volumes:
      - ./meshviewer/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./meshviewer/config.json:/usr/share/nginx/html/config.json:ro
      - yanic:/usr/share/nginx/html/yanic:ro
    healthcheck:
      test: "nc -z localhost 80 || exit 1"
      interval: 60s
      timeout: 2s
      retries: 3
    hostname: meshviewer

nginx.conf

user  nginx;
worker_processes  auto;

pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;


    ###  Logs anonymisieren: Letzte Stelle durch 0 ersetzen ###
    # normale zugriffe
    map $remote_addr $remote_addr1 {
        default 0.0.0;
        "~(?P<ip>(\d+)\.(\d+)\.(\d+))\.\d+" $ip;
        "~(?P<ip>[^:]+:[^:]+):" $ip;
    }
    map $remote_addr $remote_addr2 {
    default .0;
        "~(?P<ip>(\d+)\.(\d+)\.(\d+))\.\d+" .0;
        "~(?P<ip>[^:]+:[^:]+):" ::;
    }
    map $remote_addr1$remote_addr2 $remote_addr_anon {
        default 0.0.0.0;
        "~(?P<ip>.*)" $ip;
    }

    # reverse proxy (X-Forwarded-For)
    map $http_x_forwarded_for $http_x_forwarded_for_anon1 {
        default 0.0.0;
        "~(?P<ip>(\d+)\.(\d+)\.(\d+))\.\d+" $ip;
        "~(?P<ip>[^:]+:[^:]+):" $ip;
    }
    map $http_x_forwarded_for $http_x_forwarded_for_anon2 {
        default .0;
        "~(?P<ip>(\d+)\.(\d+)\.(\d+))\.\d+" .0;
        "~(?P<ip>[^:]+:[^:]+):" ::;
    }
    map $http_x_forwarded_for_anon1$http_x_forwarded_for_anon2 $http_x_forwarded_for_anon {
        default 0.0.0.0;
        "~(?P<ip>.*)" $ip;
    }

    log_format anonymized '$remote_addr_anon - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '$http_user_agent" "$http_x_forwarded_for_anon"';

    access_log            /var/log/nginx/access.log anonymized;
    error_log             /var/log/nginx/error.log warn;


    ### Verzeichnis für OSM tiles cache, wird automatisch angelegt ###
    proxy_cache_path /var/cache/nginx/tiles_cache levels=1:2 keys_zone=tiles_cache:64m inactive=7d max_size=2G;
    upstream openstreetmap_backend {
        server a.tile.openstreetmap.org;
        server b.tile.openstreetmap.org;
        server c.tile.openstreetmap.org;
    }


    server {
        listen 80;

        # Meshviewer
        location / {
            root /usr/share/nginx/html;
            index index.html index.htm;
        }

        # Yanic mapdata
        location /yanic {
            root /usr/share/nginx/html;
            expires -1;
        }

        # OSM tiles cache
        location /tiles_cache {
            proxy_set_header          X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header          Host tile.openstreetmap.org;
            add_header                X-Cache-Status $upstream_cache_status;

            rewrite                   ^/tiles_cache(/.*)$ $1 break;
            proxy_pass                http://openstreetmap_backend;

            proxy_cache               tiles_cache;
            proxy_cache_valid         202 302 7d;
            proxy_cache_valid         404 1m;
            proxy_cache_lock          on;
            proxy_cache_use_stale     error timeout http_500 http_502 http_503 http_504;
        }
    }
}

Tag summary

Content type

Image

Digest

sha256:ea6e4d8b6…

Size

36.1 MB

Last updated

24 days ago

docker pull ffin/meshviewer