Applications shouldn't handle SSL, WAF, rate limiting or load balancing directly. These are infrastructure responsibilities.
Architecture components
- HAProxy + keepalived HA
- Nginx reverse proxy
- Varnish HTTP cache
- Traefik for containers
- ModSecurity WAF
- Let's Encrypt
What we deliver
HA reverse proxy cluster, auto-renewable SSL, WAF, monitoring dashboards.
Example: Nginx reverse proxy
A minimal, ready-to-use block for an app behind Nginx with TLS:
# /etc/nginx/conf.d/app.conf — reverse proxy + TLS
server {
listen 443 ssl;
server_name app.example.com;
ssl_certificate /etc/letsencrypt/live/app.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/app.example.com/privkey.pem;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
HAProxy: backend with health checks
A HAProxy backend with active server health checks:
frontend web
bind *:443 ssl crt /etc/haproxy/certs/site.pem
default_backend app
backend app
balance leastconn
option httpchk GET /health
http-check expect status 200
server app1 10.0.0.11:8080 check inter 2s fall 3 rise 2
server app2 10.0.0.12:8080 check inter 2s fall 3 rise 2
Nginx: rate limiting against abuse
You limit requests per IP to stop scraping and L7 attacks:
# in http {}
limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;
# in location
location /api/ {
limit_req zone=api burst=20 nodelay;
limit_req_status 429;
proxy_pass http://app;
}
Nginx: cache for public content
You cache responses to reduce load on the app:
# in http {}
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=app:50m max_size=2g inactive=60m;
# in location
location / {
proxy_cache app;
proxy_cache_valid 200 10m;
proxy_cache_use_stale error timeout updating;
add_header X-Cache $upstream_cache_status;
proxy_pass http://backend;
}
WAF: ModSecurity + OWASP CRS
You block injections and L7 attacks with a WAF:
apt -y install libnginx-mod-http-modsecurity
# activezi + OWASP Core Rule Set
git clone https://github.com/coreruleset/coreruleset /etc/nginx/owasp-crs
# nginx.conf: modsecurity on; modsecurity_rules_file /etc/nginx/modsec/main.conf;
# incepi in DetectionOnly, apoi treci pe blocking dupa tuning
nginx -t && systemctl reload nginx