mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-04 18:14:53 +02:00
Reorg; create crowdsec folder properly now
This commit is contained in:
parent
81c4199e87
commit
60449afca5
15 changed files with 349 additions and 285 deletions
18
install/config/crowdsec/acquis.yaml
Normal file
18
install/config/crowdsec/acquis.yaml
Normal file
|
@ -0,0 +1,18 @@
|
|||
filenames:
|
||||
- /var/log/auth.log
|
||||
- /var/log/syslog
|
||||
labels:
|
||||
type: syslog
|
||||
---
|
||||
poll_without_inotify: false
|
||||
filenames:
|
||||
- /var/log/traefik/*.log
|
||||
labels:
|
||||
type: traefik
|
||||
---
|
||||
listen_addr: 0.0.0.0:7422
|
||||
appsec_config: crowdsecurity/appsec-default
|
||||
name: myAppSecComponent
|
||||
source: appsec
|
||||
labels:
|
||||
type: appsec
|
12
install/config/crowdsec/config.yaml
Normal file
12
install/config/crowdsec/config.yaml
Normal file
|
@ -0,0 +1,12 @@
|
|||
api:
|
||||
client:
|
||||
insecure_skip_verify: false
|
||||
credentials_path: /etc/crowdsec/local_api_credentials.yaml
|
||||
server:
|
||||
log_level: info
|
||||
listen_uri: 0.0.0.0:9090
|
||||
profiles_path: /etc/crowdsec/profiles.yaml
|
||||
trusted_ips:
|
||||
- 0.0.0.0/0
|
||||
- 127.0.0.1
|
||||
- ::1
|
108
install/config/crowdsec/dynamic_config.yml
Normal file
108
install/config/crowdsec/dynamic_config.yml
Normal file
|
@ -0,0 +1,108 @@
|
|||
http:
|
||||
middlewares:
|
||||
redirect-to-https:
|
||||
redirectScheme:
|
||||
scheme: https
|
||||
default-whitelist: # Whitelist middleware for internal IPs
|
||||
ipWhiteList: # Internal IP addresses
|
||||
sourceRange: # Internal IP addresses
|
||||
- "10.0.0.0/8" # Internal IP addresses
|
||||
- "192.168.0.0/16" # Internal IP addresses
|
||||
- "172.16.0.0/12" # Internal IP addresses
|
||||
# Basic security headers
|
||||
security-headers:
|
||||
headers:
|
||||
customResponseHeaders: # Custom response headers
|
||||
Server: "" # Remove server header
|
||||
X-Powered-By: "" # Remove powered by header
|
||||
X-Forwarded-Proto: "https" # Set forwarded proto to https
|
||||
sslProxyHeaders: # SSL proxy headers
|
||||
X-Forwarded-Proto: "https" # Set forwarded proto to https
|
||||
hostsProxyHeaders: # Hosts proxy headers
|
||||
- "X-Forwarded-Host" # Set forwarded host
|
||||
contentTypeNosniff: true # Prevent MIME sniffing
|
||||
customFrameOptionsValue: "SAMEORIGIN" # Set frame options
|
||||
referrerPolicy: "strict-origin-when-cross-origin" # Set referrer policy
|
||||
forceSTSHeader: true # Force STS header
|
||||
stsIncludeSubdomains: true # Include subdomains
|
||||
stsSeconds: 63072000 # STS seconds
|
||||
stsPreload: true # Preload STS
|
||||
# CrowdSec configuration with proper IP forwarding
|
||||
crowdsec:
|
||||
plugin:
|
||||
crowdsec:
|
||||
enabled: true # Enable CrowdSec plugin
|
||||
logLevel: INFO # Log level
|
||||
updateIntervalSeconds: 15 # Update interval
|
||||
updateMaxFailure: 0 # Update max failure
|
||||
defaultDecisionSeconds: 15 # Default decision seconds
|
||||
httpTimeoutSeconds: 10 # HTTP timeout
|
||||
crowdsecMode: live # CrowdSec mode
|
||||
crowdsecAppsecEnabled: true # Enable AppSec
|
||||
crowdsecAppsecHost: crowdsec:7422 # CrowdSec IP address which you noted down later
|
||||
crowdsecAppsecFailureBlock: true # Block on failure
|
||||
crowdsecAppsecUnreachableBlock: true # Block on unreachable
|
||||
crowdsecLapiKey: "{{.TraefikBouncerKey}}" # CrowdSec API key which you noted down later
|
||||
crowdsecLapiHost: crowdsec:9090 # CrowdSec
|
||||
crowdsecLapiScheme: http # CrowdSec API scheme
|
||||
forwardedHeadersTrustedIPs: # Forwarded headers trusted IPs
|
||||
- "0.0.0.0/0" # All IP addresses are trusted for forwarded headers (CHANGE MADE HERE)
|
||||
clientTrustedIPs: # Client trusted IPs (CHANGE MADE HERE)
|
||||
- "10.0.0.0/8" # Internal LAN IP addresses
|
||||
- "172.16.0.0/12" # Internal LAN IP addresses
|
||||
- "192.168.0.0/16" # Internal LAN IP addresses
|
||||
- "100.89.137.0/20" # Internal LAN IP addresses
|
||||
|
||||
routers:
|
||||
# HTTP to HTTPS redirect router
|
||||
main-app-router-redirect:
|
||||
rule: "Host(`{{.DashboardDomain}}`)" # Dynamic Domain Name
|
||||
service: next-service
|
||||
entryPoints:
|
||||
- web
|
||||
middlewares:
|
||||
- redirect-to-https
|
||||
|
||||
# Next.js router (handles everything except API and WebSocket paths)
|
||||
next-router:
|
||||
rule: "Host(`{{.DashboardDomain}}`) && !PathPrefix(`/api/v1`)" # Dynamic Domain Name
|
||||
service: next-service
|
||||
entryPoints:
|
||||
- websecure
|
||||
middlewares:
|
||||
- security-headers # Add security headers middleware
|
||||
tls:
|
||||
certResolver: letsencrypt
|
||||
|
||||
# API router (handles /api/v1 paths)
|
||||
api-router:
|
||||
rule: "Host(`{{.DashboardDomain}}`) && PathPrefix(`/api/v1`)" # Dynamic Domain Name
|
||||
service: api-service
|
||||
entryPoints:
|
||||
- websecure
|
||||
middlewares:
|
||||
- security-headers # Add security headers middleware
|
||||
tls:
|
||||
certResolver: letsencrypt
|
||||
|
||||
# WebSocket router
|
||||
ws-router:
|
||||
rule: "Host(`{{.DashboardDomain}}`)" # Dynamic Domain Name
|
||||
service: api-service
|
||||
entryPoints:
|
||||
- websecure
|
||||
middlewares:
|
||||
- security-headers # Add security headers middleware
|
||||
tls:
|
||||
certResolver: letsencrypt
|
||||
|
||||
services:
|
||||
next-service:
|
||||
loadBalancer:
|
||||
servers:
|
||||
- url: "http://pangolin:3002" # Next.js server
|
||||
|
||||
api-service:
|
||||
loadBalancer:
|
||||
servers:
|
||||
- url: "http://pangolin:3000" # API/WebSocket server
|
2
install/config/crowdsec/local_api_credentials.yaml
Normal file
2
install/config/crowdsec/local_api_credentials.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
url: http://0.0.0.0:9090
|
||||
login: localhost
|
25
install/config/crowdsec/profiles.yaml
Normal file
25
install/config/crowdsec/profiles.yaml
Normal file
|
@ -0,0 +1,25 @@
|
|||
name: captcha_remediation
|
||||
filters:
|
||||
- Alert.Remediation == true && Alert.GetScope() == "Ip" && Alert.GetScenario() contains "http"
|
||||
decisions:
|
||||
- type: captcha
|
||||
duration: 4h
|
||||
on_success: break
|
||||
|
||||
---
|
||||
name: default_ip_remediation
|
||||
filters:
|
||||
- Alert.Remediation == true && Alert.GetScope() == "Ip"
|
||||
decisions:
|
||||
- type: ban
|
||||
duration: 4h
|
||||
on_success: break
|
||||
|
||||
---
|
||||
name: default_range_remediation
|
||||
filters:
|
||||
- Alert.Remediation == true && Alert.GetScope() == "Range"
|
||||
decisions:
|
||||
- type: ban
|
||||
duration: 4h
|
||||
on_success: break
|
87
install/config/crowdsec/traefik_config.yml
Normal file
87
install/config/crowdsec/traefik_config.yml
Normal file
|
@ -0,0 +1,87 @@
|
|||
api:
|
||||
insecure: true
|
||||
dashboard: true
|
||||
|
||||
providers:
|
||||
http:
|
||||
endpoint: "http://pangolin:3001/api/v1/traefik-config"
|
||||
pollInterval: "5s"
|
||||
file:
|
||||
filename: "/etc/traefik/dynamic_config.yml"
|
||||
|
||||
experimental:
|
||||
plugins:
|
||||
badger:
|
||||
moduleName: "github.com/fosrl/badger"
|
||||
version: "{{.BadgerVersion}}"
|
||||
crowdsec: # CrowdSec plugin configuration added
|
||||
moduleName: "github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin"
|
||||
version: "v1.3.5"
|
||||
|
||||
log:
|
||||
level: "INFO"
|
||||
format: "json" # Log format changed to json for better parsing
|
||||
|
||||
accessLog: # We enable access logs as json
|
||||
filePath: "/var/log/traefik/access.log"
|
||||
format: json
|
||||
filters:
|
||||
statusCodes:
|
||||
- "200-299" # Success codes
|
||||
- "400-499" # Client errors
|
||||
- "500-599" # Server errors
|
||||
retryAttempts: true
|
||||
minDuration: "100ms" # Increased to focus on slower requests
|
||||
bufferingSize: 100 # Add buffering for better performance
|
||||
fields:
|
||||
defaultMode: drop # Start with dropping all fields
|
||||
names:
|
||||
ClientAddr: keep # Keep client address for IP tracking
|
||||
ClientHost: keep # Keep client host for IP tracking
|
||||
RequestMethod: keep # Keep request method for tracking
|
||||
RequestPath: keep # Keep request path for tracking
|
||||
RequestProtocol: keep # Keep request protocol for tracking
|
||||
DownstreamStatus: keep # Keep downstream status for tracking
|
||||
DownstreamContentSize: keep # Keep downstream content size for tracking
|
||||
Duration: keep # Keep request duration for tracking
|
||||
ServiceName: keep # Keep service name for tracking
|
||||
StartUTC: keep # Keep start time for tracking
|
||||
TLSVersion: keep # Keep TLS version for tracking
|
||||
TLSCipher: keep # Keep TLS cipher for tracking
|
||||
RetryAttempts: keep # Keep retry attempts for tracking
|
||||
headers:
|
||||
defaultMode: drop # Start with dropping all headers
|
||||
names:
|
||||
User-Agent: keep # Keep user agent for tracking
|
||||
X-Real-Ip: keep # Keep real IP for tracking
|
||||
X-Forwarded-For: keep # Keep forwarded IP for tracking
|
||||
X-Forwarded-Proto: keep # Keep forwarded protocol for tracking
|
||||
Content-Type: keep # Keep content type for tracking
|
||||
Authorization: redact # Redact sensitive information
|
||||
Cookie: redact # Redact sensitive information
|
||||
|
||||
certificatesResolvers:
|
||||
letsencrypt:
|
||||
acme:
|
||||
httpChallenge:
|
||||
entryPoint: web
|
||||
email: "{{.LetsEncryptEmail}}"
|
||||
storage: "/letsencrypt/acme.json"
|
||||
caServer: "https://acme-v02.api.letsencrypt.org/directory"
|
||||
|
||||
entryPoints:
|
||||
web:
|
||||
address: ":80"
|
||||
websecure:
|
||||
address: ":443"
|
||||
transport:
|
||||
respondingTimeouts:
|
||||
readTimeout: "30m"
|
||||
http:
|
||||
tls:
|
||||
certResolver: "letsencrypt"
|
||||
middlewares: # CHANGE MADE HERE (BOUNCER ENABLED) !!!
|
||||
- crowdsec@file
|
||||
|
||||
serversTransport:
|
||||
insecureSkipVerify: true
|
Loading…
Add table
Add a link
Reference in a new issue