Nginx redirect für darkstat

karloff

karloff

Routinier
Moin,
zur Zeit muss ich einen Server überwachen um die quelle für traffic spitzen zu finden.
Dafür scheint darkstat die richtige Wahl zu sein um schon mal zu schauen von welchem Port der Traffic ausgeht.

Da der Server in nem Rechenzentrum steht das da mit localhost nicht so einfach.
Ebenfalls möchte ich das ding nicht einfach so öffentlich an nem port lauschen lassen.

Ergo redirect via nginx.

Die config sieht zur Zeit so aus:
Code:
location /darkstat {
        proxy_pass [url]http://localhost:6660;[/url]
        proxy_redirect [url]http://localhost:6660/[/url] http://$host:$server_port/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
Soll wenn es läuft noch ne passwortabfrage spendiert bekommen, aber das steht noch auf der todo liste.

Das Problem ist jetzt das der forward zwar funktioniert allerdings ein
Code:
NOT Found
The Page you requested could not be found.

Generated by darkstat/3.0.718

Das Problem ist jetzt das ich nich genau weiß wo es klemmt, der Port redirect scheint ja zu klappen und wird von darkstat bearbeitet, allerdings liefert der nur ein not found.

Natürlich habe ich schon versucht das ding an die externe ip zu binden, dann klappt es auch und ich bekomme meine statistik.
Nur der forward läuft nicht rund.

Hat da jemand ne Idee / Tipp ?
 
Abend,

erstens Danke: hat mich dazu gebracht mich mal mit Nginix zu beschäftigen, was ich schon längst tun hätte müssen/sollen

zweitens:

Darkstat.config:
Code:
root@minion:/var/log/nginx# cat /etc/darkstat/init.cfg
# Turn this to yes when you have configured the options below.
START_DARKSTAT=yes

# Don't forget to read the man page.

# You must set this option, else darkstat may not listen to
# the interface you want
INTERFACE="-i lo"

#DIR="/var/lib/darkstat"
PORT="-p 6660"
BINDIP="-b 127.0.0.1"
#LOCAL="-l 192.168.0.0/255.255.255.0"

# File will be relative to $DIR:
#DAYLOG="--daylog darkstat.log"

# Don't reverse resolve IPs to host names
#DNS="--no-dns"

#FILTER="not (src net 192.168.0 and dst net 192.168.0)"

# Additional command line Arguments:
OPTIONS="--syslog --no-macs --local-only"


nginx:
Code:
        location /darkstat/ {
                proxy_set_header X-Real-IP  $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_set_header Host $host;
                proxy_pass http://127.0.0.1:6660;

                rewrite    /darkstat/(.*) /$1 break;
        }


Das Problem:

Der nginx reicht bei proxy_pass die "URI" mit nginx.org ... ngx_http_proxy_module.html,
daraus wird dann im tcpdump:
Code:
 ... GET./darkstat/ HTTP/1.0 ....
Macht man den tcpdump während man mittels curl / lynx / whatever direkt auf darkstat zugreift siet das so aus:
Code:
 ... GET./ HTTP/1.0 ....
deshalb schreiben wir die URI im nginx um
Code:
 rewrite    /darkstat/(.*) /$1 break;

mfg
HeadCrash
 

Ähnliche Themen

nginx owncloud, php? Problem

dovecot und postfix Konfiguration Problem

squid transparent proxy will nicht transparent werden !! :-(

Squid nur zum maskieren der eigenen IP, nicht für Webserver auf port 80

Jaunty + Zend + Gdata + xampp

Zurück
Oben