Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Met error "上传失败 可能是文件体积过大", but fixed with deepseek #280

Open
Onionbai opened this issue Feb 28, 2025 · 0 comments

Comments

@Onionbai
Copy link

Onionbai commented Feb 28, 2025

Using default nginx config for reverse proxy, but meeting errors "上传失败 可能是文件体积过大", have assured that all tailchat concerned containers have been removed and started more than once, error still exists.

After check the source code, found this

export async function uploadFile(
  file: File,
  options: UploadFileOptions = {}
): Promise<UploadFileResult> {
  const form = new FormData();
  form.append('file', file);
  form.append('usage', options.usage ?? 'unknown');

  const uploadFileLimit = getGlobalConfig().uploadFileLimit;
  if (file.size > uploadFileLimit) {
    // 文件过大
    showErrorToasts(
      `${t('上传失败, 支持的文件最大大小为:')} ${filesize(uploadFileLimit, {
        base: 2,
      })}`
    );
    throw new Error('File Too Large');
  }

  try {
    const { data } = await request.post('/upload', form, {
      onUploadProgress(progressEvent) {
        if (progressEvent.lengthComputable) {
          if (typeof options.onProgress === 'function') {
            options.onProgress(
              progressEvent.loaded / progressEvent.total,
              progressEvent
            );
          }
        }
      },
    });

    return data;
  } catch (e) {
    showToasts(`${t('上传失败')}: ${t('可能是文件体积过大')}`, 'error');
    console.error(`${t('上传失败')}: ${_get(e, 'message')}`);
    throw e;
  }
}

So I guess this error was not raised by tailchat but nginx.
Whatever, this is a better config for nginx, if here were any mistake, that would all deepseek's fault😁, but I have tested in nginx 1.26.2, here is nothing wrong with it. I suggest @moonrailgun updating nginx default config
Enjoy.

gzip on;
gzip_types
    text/css
    text/javascript
    application/javascript
    application/json;

map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
}

server {
    listen 80;
    listen [::]:80;
    server_name tailchat.domain.com;
    return 301 https://$host$request_uri;  
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name tailchat.domain.com;


    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
    ssl_prefer_server_ciphers on;
    ssl_ecdh_curve secp384r1;  
    ssl_session_timeout 1d;
    ssl_session_cache shared:SSL:10m;
    ssl_session_tickets off;
    ssl_stapling on;
    ssl_stapling_verify on;
    ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;

    ssl_certificate /etc/cert/tailchat.domain.com;
    ssl_certificate_key /etc/cert/tailchat.domain.com;

    add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;


    proxy_http_version 1.1;
    proxy_redirect off;
    proxy_set_header Host $http_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_max_temp_file_size 1024m;
    client_max_body_size 1024M;


    location ~ ^/socket\.io(/|$) {
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade; 
        proxy_pass http://127.0.0.1:11000;
        proxy_read_timeout 86400;
    }


    location / {
        proxy_pass http://127.0.0.1:11000;
    }


    add_header X-Content-Type-Options "nosniff" always;
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-XSS-Protection "1; mode=block" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;


    access_log /var/log/nginx/tailchat-access.log combined buffer=64k flush=5m;
    error_log /var/log/nginx/tailchat-error.log warn;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant