[Solved] URL Encoding issues when upload files with spaces or special characters

(this thread is a follow up of this issue: https://github.com/pydio/cells/issues/185)

Hi !
As explained on GitHub before, I have troubles upload any file with special characters or spaces on Cells.
Precisions: tried with a local datasource, but still nothing… It returns me a 413 error on the PUT request.

Setup:
Cells inside Docker <-> Nginx Reverse Proxy <-> Cloudflare
I copied the config from the Nginx reverse proxy tutorial (which was not working out-of-the-box btw, I needed to uncomment that line proxy_set_header Host $host;, since Nginx doesn’t pass the host by default).

Thanks for your help!
Arno

Hello @Arno500,

could you show me your nginx configuration, I will try to reproduce your case.

Here it is !
(Nginx nginx/1.16.1)

    server_name outside.host;
        location / {
                proxy_buffering off;
                proxy_pass https://localhost:9008;
                # Removed $request_uri here since it should be automatically passed (and tried with a slash at the end too, to no avail)
                #proxy_pass_request_headers      on;
                proxy_ssl_server_name on;
                proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

                proxy_set_header  Host $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-Host $server_name;
                proxy_set_header  Client-IP $remote_addr;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
        }

        location /ws {
                proxy_buffering off;
                proxy_pass https://localhost:9008;
                proxy_set_header  Host $host;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_read_timeout 86400;
        }

        listen 443 ssl;
        listen [::]:443 ssl;
        include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_certificate /etc/nginx/cert.pem;
    ssl_certificate_key /etc/nginx/privkey.pem;
    }

Hello @Arno500,

Could you tell me about the following points:

  1. Are the files that you try to upload empty? (If that is the case could you try to put One char in the files and upload them once again)

  2. Could you give me some filenames that are failing? (I tried with spaces with\ a\ space.txt, $, !...)

Hello !

  1. No, these are data files (I used songs for my tests)
  2. For instance: 01 みちしるべ.m4a doesn’t pass. Something like Cover.jpg does, though. This one doesn’t, neither: 03 White ambitions.m4a

So, I tried with the first name that you gave me and it worked for me.

(This is from my nginx access logs)

88.190.116.42 - - [12/Dec/2019:11:55:35 +0100] "PUT /io/personal-files/01%20%E3%81%BF%E3%81%A1%E3%81%97%E3%82%8B%E3%81%B9.m4a?AWSAccessKeyId=gateway&Content-Type=application%2Foctet-stream&Expires=1576149035&Signature=hPiscZnla5biikMkFEBVtRUQqLw%3D HTTP/2.0" 200 0 "https://test-proxy-apache.ci.pyd.io/ws-personal-files/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"

Second name also went well (03 White ambitions.m4a).

Here is my working nginx config

server {
        client_max_body_size 200M;
        server_name test-cells.io;

        location / {
                proxy_buffering off;
                proxy_pass http://localhost:8080$request_uri;
                #proxy_pass_request_headers on;
                #proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
        }

        location /ws {
                proxy_buffering off;
                proxy_pass http://localhost:8080;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_read_timeout 86400;
        }

        error_log /var/log/nginx/cells-proxy-error.log;
        access_log /var/log/nginx/cells-proxy-access.log;


    listen [::]:443 ssl http2; # managed by Certbot
    listen 443 ssl http2; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/test-cells.io/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/test-cells.io/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    if ($host = test-cells.io) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        listen 80 http2;
        listen [::]:80 http2;
        server_name test-cells.io;
        return 404; # managed by Certbot

}

Edit: If it still does not work could you show me your Nginx logs when you attempt an upload and also Cells logs.

1 Like

After fiddling with the settings you gave me, I found the culprit: It was client_max_body_size 200M;
For some reason, if we omit this configuration key, the whole upload just crash. I find it a bit strange, and don’t know why Nginx (or Caddy behind, or even Cells) sends me this 413 if I don’t specify it…
Still, it’s working now, so thanks and sorry for wasting your time!

no worries, glad that you figured what was messing things up.