BUH_bot/nginx/nginx.conf
Игорь Надеин 4800e8c375 feat: Add production Docker orchestration with monitoring
Production Stack (7 services):
- buh_bot: Main bot from registry (1 CPU, 1GB RAM)
- nginx: Reverse proxy with rate limiting (10 req/s)
- prometheus: Metrics collection (30d retention)
- grafana: Monitoring dashboards (port 3000)
- node_exporter: Host metrics (port 9100)
- cadvisor: Container metrics (port 8080)
- watchtower: Auto-updates (hourly check)

Configuration:
- docker-compose.prod.yml with 7-service stack
- nginx.conf with SSL-ready config and healthchecks
- prometheus.yml with scrape configs
- grafana datasource and dashboard provisioning
- .env.prod.example template
- Custom network 172.20.0.0/16
- Persistent volumes in /var/lib/buh_bot
- Log rotation: 50MB x 5 files
2025-11-03 14:20:48 +03:00

88 lines
2.4 KiB
Nginx Configuration File

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
multi_accept on;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Логирование
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
# Производительность
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
client_max_body_size 20M;
# Gzip сжатие
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml text/javascript
application/json application/javascript application/xml+rss;
# SSL параметры
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
# Rate limiting
limit_req_zone $binary_remote_addr zone=bot_limit:10m rate=10r/s;
limit_conn_zone $binary_remote_addr zone=conn_limit:10m;
# Healthcheck endpoint
server {
listen 80;
server_name _;
location /health {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
location /metrics {
access_log off;
return 200 "nginx_up 1\n";
add_header Content-Type text/plain;
}
}
# Webhook endpoint (если используется)
# server {
# listen 443 ssl http2;
# server_name your-domain.com;
#
# ssl_certificate /etc/nginx/ssl/fullchain.pem;
# ssl_certificate_key /etc/nginx/ssl/privkey.pem;
#
# location /webhook {
# limit_req zone=bot_limit burst=20 nodelay;
# limit_conn conn_limit 10;
#
# proxy_pass http://buh_bot:8443;
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto $scheme;
# }
# }
}