Hallo zusammen,
Hat schonmal wer den Rev. Proxy Nginx und Crowdsec auf der Opensense installiert. Würde gerne eine kleine Installation absichern.
Aktuell sehe ich den Ngix nicht im Collector. Wie muss ich 
Crowdsec.JPG
Würde gerne wenn z.B. zu viele Anmeldeversuche stattfinden die IPs sperren.
			
			
			
				hat keiner CrowdSec inkl. Reverse Proxy im Einsatz?
			
			
			
				Doch, ich benutze dafür Caddy. Andere haben es auch mit HA Proxy laufen.
Hier ein beispiel wie es mit Caddy geht, mit NGINX geht es wahrscheinlich genauso wenn man die collection installiert und die Access Logs auswerten lässt.
https://docs.opnsense.org/manual/how-tos/caddy.html#crowdsec-integration
			
			
			
				Danke das kenne ich.
Wenn ich mir die Config des Nginx ansehe wird hier das Logfile umgeleitet. Sehe ich das richtig?
# configuration file /usr/local/etc/nginx/nginx.conf:
load_module /usr/local/libexec/nginx/ngx_stream_module.so;
load_module /usr/local/libexec/nginx/ngx_http_naxsi_module.so;
load_module /usr/local/libexec/nginx/ngx_mail_module.so;
load_module /usr/local/libexec/nginx/ngx_http_brotli_filter_module.so;
load_module /usr/local/libexec/nginx/ngx_http_brotli_static_module.so;
load_module /usr/local/libexec/nginx/ngx_http_js_module.so;
load_module /usr/local/libexec/nginx/ngx_http_vhost_traffic_status_module.so;
user www staff;
worker_processes 2;
#error_log  /var/log/nginx/error.log;
error_log  syslog:server=unix:/var/run/log,facility=local6,nohostname warn;
events {
    worker_connections  1024;
}
http {
include       mime.types;
log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';
log_format  main_ext  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for" '
                      '"$host" sn="$server_name" '
                      'rt=$request_time '
                      'ua="$upstream_addr" us="$upstream_status" '
                      'ut="$upstream_response_time" ul="$upstream_response_length" '
                      'cs=$upstream_cache_status';
log_format  handshake   '"$http_user_agent" "$ssl_ciphers" "$ssl_curves"';
log_format  anonymized  ':: - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';
#tcp_nopush     on;
# https intercept detection
js_import /usr/local/opnsense/scripts/nginx/ngx_functions.js;
js_set $tls_intercepted ngx_functions.check_intercept;
Was muss ich nun in der CrowdSec collection Config eintragen?
			
			
			
				Weis ich leider nicht, am besten mal in der Crowdsec Community fragen, da gibt es wahrscheinlich mehr die nginx damit nutzen und helfen können.
			
			
			
				cscli collections install crowdsecurity/nginx
Und dann im acquis.d ungefähr so:
filenames:
  - /var/log/nginx/*.log
labels:
  type: nginx
Alles ausführlich dokumentiert:
https://app.crowdsec.net/hub/author/crowdsecurity/collections/nginx
			
			
			
				Danke für die Hilfe,
Es scheint soweit richtig installiert zu sein.
root@OPNsense:~ # cscli metrics
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Acquisition Metrics                                                                                                                                                  │
├────────────────────────────────────────────────────────────────────────────┬────────────┬──────────────┬────────────────┬────────────────────────┬───────────────────┤
│ Source                                                                     │ Lines read │ Lines parsed │ Lines unparsed │ Lines poured to bucket │ Lines whitelisted │
├────────────────────────────────────────────────────────────────────────────┼────────────┼──────────────┼────────────────┼────────────────────────┼───────────────────┤
│ file:/var/log/audit/latest.log                                             │ 2.66k      │ -            │ 2.66k          │ -                      │ -                 │
│ file:/var/log/filter/latest.log                                            │ 52.33k     │ 14.72k       │ 37.61k         │ 10.75k                 │ -                 │
│ file:/var/log/lighttpd/latest.log                                          │ 9          │ -            │ 9              │ -                      │ -                 │
│ file:/var/log/nginx/error.log                                              │ 2          │ -            │ 2              │ -                      │ -                 │
│ file:/var/log/nginx/locatehub1.xxxxxxxxxxxxxxxx.access.log                 │ 36         │ 2            │ 34             │ 1                      │ -                 │
│ file:/var/log/nginx/stream_b1c0dda5-30ea-47f2-acf1-5e75daed48d6.access.log │ 12         │ -            │ 12             │ -                      │ -                 │
│ file:/var/log/nginx/stream_b1c0dda5-30ea-47f2-acf1-5e75daed48d6.error.log  │ 36         │ -            │ 36             │ -                      │ -                 │
│ file:/var/log/nginx/tls_handshake.log                                      │ 95         │ -            │ 95             │ -                      │ -                 │
│ file:/var/log/nginx/visuserver.xxxxxxxxxxxxxxxx.access.log                 │ 41         │ 35           │ 6              │ 11                     │ -                 │
╰────────────────────────────────────────────────────────────────────────────┴────────────┴──────────────┴────────────────┴────────────────────────┴───────────────────╯
Leider werde ich nie blockiert. Die Lines read, Lines parsed ... bleiben fast konstant.