Freifunk-Potsdam / ffp-monitor

3 stars 1 forks source link

Wie aufsetzen? #5

Open niccokunzmann opened 4 years ago

niccokunzmann commented 4 years ago

Es gibt hier nur Scripts und keine README. Wenn ich das verbessern möchte, hätte ich gerne eine kleine Beschreibung, wie ich das aufsetze. Das macht es mir dann leichter.

seth0r commented 4 years ago

Die scripte werden via mod_wsgi beim apache eingebunden, hier unsere configs:

HTTP:

<VirtualHost *:80>
    ServerName monitor.freifunk-potsdam.de

    ServerAdmin postmaster@freifunk-potsdam.de

    KeepAlive Off
    SSLProxyEngine On

    RewriteEngine on
    RewriteRule "^/\.well-known/acme-challenge/.*" "-" [END]
    RewriteRule "^/fff" "/ff/feed" [PT]
    RewriteRule "^/ffp-collect" "https://monitor.freifunk-potsdam.de/ffp-collect" [P]
    RewriteRule "^/ff/feed" "-" [S=1]
    RewriteRule "(.*)" "https://%{HTTP_HOST}%{REQUEST_URI}" [R=303,L]

    Alias /.well-known/acme-challenge/ /var/www/acme-challenges/

    <Directory /var/www/acme-challenges/> 
        AllowOverride None 
        Require all granted 
    </Directory>

    RewriteEngine On

    WSGIDaemonProcess fffeed python-path=/var/www/monitor.freifunk-potsdam.de/wsgi/ff threads=64 processes=1

    WSGIScriptAlias /ff /var/www/monitor.freifunk-potsdam.de/wsgi/ff/fffeed.wsgi
    <Location /ff>
            WSGIProcessGroup fffeed
    </Location>

    WSGIApplicationGroup %{GLOBAL}

    ErrorLog /var/log/apache2/monitor.freifunk-potsdam.de_error.log

    <IfModule log_config_module>
            TransferLog /var/log/apache2/monitor.freifunk-potsdam.de_access.log
    </IfModule>

    <IfModule mpm_peruser_module>
            ServerEnvironment apache apache
    </IfModule>
</VirtualHost>

HTTPS:

<VirtualHost *:443>
    ServerName monitor.freifunk-potsdam.de

    ServerAdmin postmaster@freifunk-potsdam.de
    DocumentRoot "/var/www/monitor.freifunk-potsdam.de/htdocs"

    <Directory "/var/www/monitor.freifunk-potsdam.de/htdocs">
            Options Indexes FollowSymLinks ExecCGI

            AllowOverride All

            Require all granted
    </Directory>

    #RemoteIPHeader X-Forwarded-For

    RedirectMatch 302 ^/$ /grafana/

    WSGIDaemonProcess ff python-path=/var/www/monitor.freifunk-potsdam.de/wsgi/ff threads=64 processes=1
    WSGIDaemonProcess lora python-path=/var/www/monitor.freifunk-potsdam.de/wsgi/ff threads=4 processes=1

    WSGIScriptAlias /ff /var/www/monitor.freifunk-potsdam.de/wsgi/ff/ff.wsgi
    <Location /ff>
            WSGIProcessGroup ff
    </Location>

    WSGIScriptAlias /lora /var/www/monitor.freifunk-potsdam.de/wsgi/ff/lora.wsgi
    <Location /lora>
            WSGIProcessGroup lora
    </Location>

    WSGIApplicationGroup %{GLOBAL}

    <Directory /var/www/monitor.freifunk-potsdam.de/wsgi>
        Require all granted
    </Directory>

    RequestHeader unset Authorization
    ProxyPass /grafana http://localhost:3000

    <FilesMatch "\.(cgi|shtml|phtml|php|py)$">
            SSLOptions +StdEnvVars
    </FilesMatch>

    SSLEngine on
    SSLCertificateFile /etc/ssl/letsencrypt/monitor.freifunk-potsdam.de.pem
    SSLCertificateKeyFile /etc/ssl/letsencrypt/monitor.freifunk-potsdam.de.key
    Header always set Strict-Transport-Security "max-age=15552000; includeSubdomains; preload"

    <IfModule setenvif_module>
            BrowserMatch ".*MSIE.*" \
                    nokeepalive ssl-unclean-shutdown \
                    downgrade-1.0 force-response-1.0
    </IfModule>

    ErrorLog /var/log/apache2/monitor.freifunk-potsdam.de_ssl_error.log

    <IfModule log_config_module>
            TransferLog /var/log/apache2/monitor.freifunk-potsdam.de_ssl_access.log
    </IfModule>

</VirtualHost>

Dazu kommen dann noch reichlich Cronjobs:

MAILTO="admin@server"
#bekommt die ausgaben der cronjobs
# parsing
# 0,5,10,...
*/5  *  * * *   www-data    /var/www/monitor.freifunk-potsdam.de/wsgi/ff/parseff1.py /var/ffdata/ >> /var/ffdata/ffdata.log
# 4,9,14,...
4-59/5 * * * *  www-data    /var/www/monitor.freifunk-potsdam.de/wsgi/ff/parseff2.py
59   *  * * *   root        cat /var/ffdata/ffdata.log && rm /var/ffdata/ffdata.log
1    *  * * *   www-data    find /var/ffdata/mv/ -type f -ctime +1 -delete
0    7  * * *   www-data    find /var/ffdata/err/ -size -100c -delete
2    7  * * *   www-data    ionice -c idle mv /var/ffdata/err/* /var/ffdata/

*/15 *  * * *   www-data    /var/www/monitor.freifunk-potsdam.de/wsgi/ff/lperf.py
8    *  * * *   www-data    /var/www/monitor.freifunk-potsdam.de/wsgi/ff/routes.py > /dev/null
#*    *  * * *   www-data    /var/www/monitor.freifunk-potsdam.de/wsgi/ff/sendmsg.py
*    *  * * *   www-data    /var/www/monitor.freifunk-potsdam.de/wsgi/ff/sendtweet.py routermsg
0    8  * * *   www-data    /var/www/monitor.freifunk-potsdam.de/wsgi/ff/sendtweet.py netstate