Files
telegram-management-system/marketing-agent/infrastructure/nginx/conf.d/api-gateway.conf
你的用户名 237c7802e5
Some checks failed
Deploy / deploy (push) Has been cancelled
Initial commit: Telegram Management System
Full-stack web application for Telegram management
- Frontend: Vue 3 + Vben Admin
- Backend: NestJS
- Features: User management, group broadcast, statistics

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-04 15:37:50 +08:00

102 lines
3.0 KiB
Plaintext

server {
listen 80;
server_name localhost;
# API versioning
set $api_version "v1";
# CORS configuration
add_header 'Access-Control-Allow-Origin' '$http_origin' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type, X-Requested-With' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
# Handle OPTIONS requests
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
# Health check endpoint
location /health {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
# Auth endpoints
location ~ ^/api/($api_version/)?auth {
limit_req zone=auth_limit burst=5 nodelay;
proxy_pass http://orchestrator;
include /etc/nginx/proxy.conf;
}
# Orchestrator service
location ~ ^/api/($api_version/)?orchestrator {
limit_req zone=api_limit burst=20 nodelay;
proxy_pass http://orchestrator;
include /etc/nginx/proxy.conf;
}
# Claude Agent service
location ~ ^/api/($api_version/)?claude {
limit_req zone=api_limit burst=10 nodelay;
proxy_pass http://claude_agent;
include /etc/nginx/proxy.conf;
}
# GramJS Adapter service
location ~ ^/api/($api_version/)?telegram {
limit_req zone=api_limit burst=20 nodelay;
proxy_pass http://gramjs_adapter;
include /etc/nginx/proxy.conf;
}
# Safety Guard service
location ~ ^/api/($api_version/)?safety {
limit_req zone=api_limit burst=30 nodelay;
proxy_pass http://safety_guard;
include /etc/nginx/proxy.conf;
}
# Analytics service
location ~ ^/api/($api_version/)?analytics {
limit_req zone=api_limit burst=50 nodelay;
proxy_pass http://analytics;
include /etc/nginx/proxy.conf;
}
# A/B Testing service
location ~ ^/api/($api_version/)?experiments {
limit_req zone=api_limit burst=20 nodelay;
proxy_pass http://ab_testing;
include /etc/nginx/proxy.conf;
}
# WebSocket endpoints
location ~ ^/ws/($api_version/)? {
proxy_pass http://orchestrator;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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;
proxy_read_timeout 86400;
}
# Static files (if any)
location /static {
alias /usr/share/nginx/html/static;
expires 30d;
add_header Cache-Control "public, immutable";
}
# Default location
location / {
return 404;
}
}