user www-data;
worker_processes auto;
pid /run/nginx.pid;
error_log /var/log/nginx/error.log;

events {
  worker_connections 1024;
}

http {
  client_max_body_size 20M;

  server {
    listen 80;
    server_name localhost;

    location / {
      proxy_pass http://localhost:3000;
      proxy_http_version 1.1; # Required for WebSocket
      proxy_set_header Upgrade $http_upgrade; # WebSocket header
      proxy_set_header Connection "upgrade"; # WebSocket header
      proxy_set_header Host $host;
      proxy_read_timeout 30m;
      proxy_connect_timeout 30m;
    }

    location /api/v1/ {
      proxy_pass http://localhost:8000;
      proxy_read_timeout 30m;
      proxy_connect_timeout 30m;
    }

    location /static {
      proxy_pass http://localhost:8000;
      proxy_read_timeout 30m;
      proxy_connect_timeout 30m;
    }

    location /app_data {
      proxy_pass http://localhost:8000;
      proxy_read_timeout 30m;
      proxy_connect_timeout 30m;
    }

    location /docs {
      proxy_pass http://localhost:8000/docs;
      proxy_read_timeout 30m;
      proxy_connect_timeout 30m;
    }
    
    location /openapi.json {
      proxy_pass http://localhost:8000/openapi.json;
      proxy_read_timeout 30m;
      proxy_connect_timeout 30m;
    }
  }
}