events {
    worker_connections 1024;
}

http {
    # Enables log and error files
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    # Defines the server listening on port 80 for HTTP requests
    server {
        listen 80;

        # Configuration for the app service
        location / {
            proxy_pass http://app:5173; # Proxies requests to the app service
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
            client_max_body_size 100M; # Allows file uploads up to 100MB
        }

        location ^~ /log/ {
            proxy_pass http://log:8080;

            chunked_transfer_encoding off;
            proxy_buffering off;
            proxy_cache off;
        }
    }
}
