UNPKG

autollama

Version:

Modern JavaScript-first RAG framework with contextual embeddings, professional CLI, and one-command deployment

645 lines (560 loc) 27.8 kB
server { listen 8082; server_name autollama.io www.autollama.io; root /usr/share/nginx/html; index index.html; # File upload configuration - 500MB limit client_max_body_size 500M; client_body_timeout 300s; client_header_timeout 300s; # Security headers add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Content-Type-Options "nosniff" always; add_header X-XSS-Protection "1; mode=block" always; add_header Referrer-Policy "no-referrer-when-downgrade" always; # API proxy to return sample data from Airtable location /api/recent-records { add_header Content-Type "application/json"; add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, POST, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; # Handle preflight OPTIONS requests if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, POST, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; add_header Content-Length 0; add_header Content-Type text/plain; return 204; } # Proxy to API service for recent records (will use real Airtable data when API keys are configured) proxy_pass http://autollama-on-hstgr:3001/api/recent-records; 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; # Fallback to sample data if API service is down proxy_intercept_errors on; error_page 502 503 504 = @recent_records_fallback; } # Fallback for recent records when API is down location @recent_records_fallback { add_header Content-Type "application/json"; add_header Access-Control-Allow-Origin *; return 200 '[]'; } # New content processing endpoint - replaces n8n webhook location /api/process-url { proxy_pass http://autollama-on-hstgr:3001/api/process-url; 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; # CORS headers add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, POST, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; # Handle preflight OPTIONS requests if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, POST, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; add_header Content-Length 0; add_header Content-Type text/plain; return 204; } # Increase timeout for processing proxy_read_timeout 300s; proxy_connect_timeout 300s; proxy_send_timeout 300s; } # Server-Sent Events endpoint for real-time processing updates location /api/process-url-stream { proxy_pass http://autollama-on-hstgr:3001/api/process-url-stream; 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; # SSE specific headers proxy_set_header Connection ''; proxy_http_version 1.1; proxy_buffering off; proxy_cache off; # CORS headers for SSE add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, POST, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization, Cache-Control"; # Handle preflight OPTIONS requests if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, POST, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization, Cache-Control"; add_header Content-Length 0; add_header Content-Type text/plain; return 204; } # Increase timeout for processing proxy_read_timeout 600s; proxy_connect_timeout 300s; proxy_send_timeout 600s; } # Original n8n webhook endpoint (disabled until workflow is fixed) location /api/recent-records-n8n { proxy_pass https://n8n.llam.ai/webhook/recent-records; proxy_ssl_verify off; proxy_ssl_server_name on; proxy_set_header Host n8n.llam.ai; 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 https; } # API endpoint to return individual record data from Airtable location /api/record { proxy_pass http://autollama-on-hstgr:3001/api/record; 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; # CORS headers add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, POST, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; # Handle preflight OPTIONS requests if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, POST, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; add_header Content-Length 0; add_header Content-Type text/plain; return 204; } # Fallback to sample data if API service is down proxy_intercept_errors on; error_page 502 503 504 = @record_fallback; } # Pipeline download endpoint location /api/pipeline/download { proxy_pass http://autollama-on-hstgr:3001/api/pipeline/download; 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; # CORS headers add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; # Handle preflight OPTIONS requests if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; add_header Content-Length 0; add_header Content-Type text/plain; return 204; } } # Knowledge base stats endpoint location /api/knowledge-base/stats { proxy_pass http://autollama-on-hstgr:3001/api/knowledge-base/stats; 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; # CORS headers add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; # Handle preflight OPTIONS requests if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; add_header Content-Length 0; add_header Content-Type text/plain; return 204; } } # Test endpoint location /api/test-endpoint { proxy_pass http://autollama-on-hstgr:3001/api/test-endpoint; 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; # CORS headers add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; } # Search endpoint for full database search location /api/search { proxy_pass http://autollama-on-hstgr:3001/api/search; 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; # CORS headers add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; # Handle preflight OPTIONS requests if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; add_header Content-Length 0; add_header Content-Type text/plain; return 204; } } # Documents endpoint for chunk explorer location /api/documents { proxy_pass http://autollama-on-hstgr:3001/api/documents; 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; # CORS headers add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; # Handle preflight OPTIONS requests if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; add_header Content-Length 0; add_header Content-Type text/plain; return 204; } } # Chunks endpoint for chunk explorer location /api/chunks { proxy_pass http://autollama-on-hstgr:3001/api/chunks; 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; # CORS headers add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; # Handle preflight OPTIONS requests if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; add_header Content-Length 0; add_header Content-Type text/plain; return 204; } } # Document-specific endpoints - must come before general /api handler location /api/document/ { proxy_pass http://autollama-on-hstgr:3001$request_uri; 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; # CORS headers add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; # Handle preflight OPTIONS requests if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; add_header Content-Length 0; add_header Content-Type text/plain; return 204; } } # Grouped search endpoint location /api/search/grouped { proxy_pass http://autollama-on-hstgr:3001/api/search/grouped; 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; # CORS headers add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; # Handle preflight OPTIONS requests if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; add_header Content-Length 0; add_header Content-Type text/plain; return 204; } } # API health check endpoint location /health { proxy_pass http://autollama-on-hstgr:3001/health; 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; # CORS headers add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; # Handle preflight OPTIONS requests if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; add_header Content-Length 0; add_header Content-Type text/plain; return 204; } } # Pipeline health check endpoint location /api/pipeline/health { proxy_pass http://autollama-on-hstgr:3001/api/pipeline/health; 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; # CORS headers add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; # Handle preflight OPTIONS requests if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; add_header Content-Length 0; add_header Content-Type text/plain; return 204; } } # Qdrant activity endpoint for RAG monitoring location /api/qdrant/activity { proxy_pass http://autollama-on-hstgr:3001/api/qdrant/activity; 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; # CORS headers add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; # Handle preflight OPTIONS requests if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; add_header Content-Length 0; add_header Content-Type text/plain; return 204; } } # PostgreSQL database statistics endpoint location /api/database/stats { proxy_pass http://autollama-on-hstgr:3001/api/database/stats; 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; # CORS headers add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; # Handle preflight OPTIONS requests if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; add_header Content-Length 0; add_header Content-Type text/plain; return 204; } } # File upload endpoint (standard) location /api/process-file { proxy_pass http://autollama-on-hstgr:3001/api/process-file; 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; # CORS headers add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, POST, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; # Handle preflight OPTIONS requests if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, POST, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; add_header Content-Length 0; add_header Content-Type text/plain; return 204; } # Extended timeouts for large file processing proxy_read_timeout 600s; proxy_connect_timeout 300s; proxy_send_timeout 600s; proxy_request_buffering off; } # Resume upload endpoint location /api/resume-upload/ { proxy_pass http://autollama-on-hstgr:3001/api/resume-upload/; 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; # SSE specific headers proxy_set_header Connection ''; proxy_http_version 1.1; proxy_buffering off; proxy_cache off; # CORS headers for SSE add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, POST, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization, Cache-Control"; # Handle preflight OPTIONS requests if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, POST, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization, Cache-Control"; add_header Content-Length 0; add_header Content-Type text/plain; return 204; } # Extended timeouts for resuming uploads proxy_read_timeout 900s; proxy_connect_timeout 300s; proxy_send_timeout 900s; } # Resumable sessions list endpoint location /api/sessions/resumable { proxy_pass http://autollama-on-hstgr:3001/api/sessions/resumable; 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; # CORS headers add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; # Handle preflight OPTIONS requests if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; add_header Content-Length 0; add_header Content-Type text/plain; return 204; } } # In-progress files endpoint location /api/in-progress { proxy_pass http://autollama-on-hstgr:3001/api/in-progress; 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; # CORS headers add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; # Handle preflight OPTIONS requests if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; add_header Content-Length 0; add_header Content-Type text/plain; return 204; } } # In-progress sessions endpoint location /api/sessions/in-progress { proxy_pass http://autollama-on-hstgr:3001/api/sessions/in-progress; 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; # CORS headers add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; # Handle preflight OPTIONS requests if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"; add_header Content-Length 0; add_header Content-Type text/plain; return 204; } } # File upload endpoint with Server-Sent Events (streaming) location /api/process-file-stream { proxy_pass http://autollama-on-hstgr:3001/api/process-file-stream; 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; # SSE specific headers proxy_set_header Connection ''; proxy_http_version 1.1; proxy_buffering off; proxy_cache off; proxy_request_buffering off; # CORS headers for SSE add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, POST, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization, Cache-Control"; # Handle preflight OPTIONS requests if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, POST, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization, Cache-Control"; add_header Content-Length 0; add_header Content-Type text/plain; return 204; } # Extended timeouts for large file processing proxy_read_timeout 900s; proxy_connect_timeout 300s; proxy_send_timeout 900s; } # Fallback for individual records when API is down location @record_fallback { add_header Content-Type "application/json"; add_header Access-Control-Allow-Origin *; return 200 '{"id":"fallback","url":"https://example.com","title":"API Service Unavailable","summary":"The API service is currently unavailable. Please try again later.","processedDate":"2025-07-24T00:00:00.000Z","category":"System","status":"Error","content":"API service is temporarily unavailable."}'; } # Serve static files location / { try_files $uri $uri/ /index.html; } # Prevent caching of JS and HTML files during development location ~* \.(js|html)$ { add_header Cache-Control "no-cache, no-store, must-revalidate"; add_header Pragma "no-cache"; add_header Expires "0"; } # Cache static assets (excluding JS which is handled above) location ~* \.(css|png|jpg|jpeg|gif|ico|svg)$ { expires 1y; add_header Cache-Control "public, immutable"; } # Gzip compression gzip on; gzip_vary on; gzip_min_length 1024; gzip_types text/plain text/css text/xml text/javascript application/javascript application/json; }