server {
    listen 80;
    server_name your-domain.com;

    # Increase client body size for uploads
    client_max_body_size 50M;

    # Proxy to Next.js app
    location / {
        proxy_pass http://hoerdle:3000;
        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;
        
        # Important: Forward range headers for audio streaming
        proxy_set_header Range $http_range;
        proxy_set_header If-Range $http_if_range;
        proxy_no_cache $http_range $http_if_range;
    }

    # Special handling for audio files (optional, for direct serving)
    location /uploads/ {
        proxy_pass http://hoerdle:3000;
        proxy_http_version 1.1;
        
        # Enable range requests
        proxy_set_header Range $http_range;
        proxy_set_header If-Range $http_if_range;
        proxy_no_cache $http_range $http_if_range;
        
        # Buffering settings for large files
        proxy_buffering off;
        proxy_request_buffering off;
        
        # Timeouts for large files
        proxy_read_timeout 300s;
        proxy_send_timeout 300s;
    }
}
