Back

Upload Document error 413

  • 0
  • Self Hosted
  • Functions
Bohda Řehák
10 Jun, 2024, 08:04

Hello everyone,

We have an Appwrite application behind an Nginx reverse proxy (setup based on @Steven guide ). We're encountering a 413 error when attempting to upload a 2MB file via a function. The _APP_STORAGE_LIMIT is set to 30000000, and client_max_body_size is set to 30M in both the server and location sections of the Nginx proxy hosts configuration.

Unfortunately, I haven't been able to find any useful logs from either Appwrite or Nginx. Could anyone suggest what might be causing this issue or how to enable more detailed logging to diagnose the problem? We are using Nginx version openresty/1.21.4.3 and Appwrite version 1.5.4.

Thanks for any help you can provide!

TL;DR
Developers experiencing issue with document upload due to error 413. Attempted various edits in Nginx configuration without success. Advised to avoid direct file editing and utilize advanced config in NPM. Discrepancy in upload limits observed between Console and Node.js function. Verified correct environment variables set, but problem persists. Nginx configuration likely the cause.
darShan
10 Jun, 2024, 08:31

You could try adding below in you server block -

TypeScript
server {
  client_max_body_size 10M;

  // other configuration here...
}
Bohda Řehák
10 Jun, 2024, 09:10

@darShan Yes, I have done that and unfortunately, it still doesn't work. 😦

darShan
10 Jun, 2024, 09:10

my bad, i missed that in your post. can you print the env vars via docker? what does it show?

Bohda Řehák
10 Jun, 2024, 09:19

Any specific vars you are looking for? Don't want to copy paste sensitive information.

TypeScript
_APP_FUNCTIONS_SIZE_LIMIT=30000000

Those vars are loaded correctly

Bohda Řehák
10 Jun, 2024, 11:06

Edit: Files that are under 1MB have no problem with upload Edit n.2: I can upload 20MB file to storage directly

Steven
10 Jun, 2024, 15:22

What do you mean you can upload directly?

I'm leaning towards something being wrong with your nginx config. This is an nginx error.

Bohda Řehák
10 Jun, 2024, 15:51

By uploading to storage directly I meant that I can go to Console -> Project -> Storage -> Create new file -> upload 20MB image. But with Node.js function I can't go over 1MB.

Regarding the configuration of Nxing, I followed the official docs of Nginx proxy manager, edited proxy host via advanced tab in web gui, edited the proxy conf outside the container and even went to the container itself to edit nginx.conf. Unfortunetly non of that worked

Steven
10 Jun, 2024, 16:30

What's the difference between nodejs function and the console. Is both through nginx?

Bohda Řehák
10 Jun, 2024, 16:36

It should be, yeah. Console is on the same domain as api requests go and since the domain is the one i have configured in nginx, they should both go through nginx.

Steven
10 Jun, 2024, 16:39

I don't recommend editing the file directly. Reading it to check what the config looks like is fine, but you should use the advanced config in NPM. Please share details of what you have configured.

Bohda Řehák
10 Jun, 2024, 16:54

At first I tried to edit advanced options like in the picture. This wasn´t working so i tried to edit the /data/nginx/custom/server_proxy.conf (with client_max_body_size 30M line ) which is included at the end of this configuration file stored in /data/nginx/proxy_host

TypeScript
map $scheme $hsts_header {
    https   "max-age=63072000; preload";
}

server {
  set $forward_scheme https;
  set $server         "appwrite-traefik";
  set $port           443;

  listen 80;
listen [::]:80;

listen 443 ssl http2;
listen [::]:443 ssl http2;


  server_name appwrite.example.com;


  # Let's Encrypt SSL
  include conf.d/include/letsencrypt-acme-challenge.conf;
  include conf.d/include/ssl-ciphers.conf;
  ssl_certificate /etc/letsencrypt/live/npm-1/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/npm-1/privkey.pem;



  # Block Exploits
  include conf.d/include/block-exploits.conf;



    # Force SSL
    include conf.d/include/force-ssl.conf;




proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;


  access_log /data/logs/proxy-host-1_access.log proxy;
  error_log /data/logs/proxy-host-1_error.log warn;


  location / {



    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $http_connection;
    proxy_http_version 1.1;


    # Proxy!
    include conf.d/include/proxy.conf;
  }


  # Custom
  include /data/nginx/custom/server_proxy[.]conf;
}

This unfortunetly didn't work either so i removed the server_proxy.conf and pasted the client_max_body_size 30M both in server block and location / block of this config file.

When even this didn´t do it, I tried to edit the nginx.conf inside the container again with client_max_body_size 30M, but already reverted this edit.

Steven
10 Jun, 2024, 17:00

And what's your function code?

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more