raftario / filite

A simple, light and standalone pastebin, URL shortener and file-sharing service
MIT License
190 stars 16 forks source link

File link generation fails when serving on subdirectory. #20

Closed luftaquila closed 4 years ago

luftaquila commented 4 years ago

I tried to serve filite on subdirectory, not on the root. My nginx configuration is:

location /u/ { proxy_pass http://localhost:7500/; } location /u/f { client_max_body_size 10M; proxy_pass http://localhost:7500/; }

Link and text works well, but file upload fails with alert window says only "Error". Filite console log looks like "PUT //76f2dy HTTP/1.0" 404 0 "https://luftaquila.io/u/"

I wonder that double slash in front of the id is just normal, or some bug caused by serving on subdirectory, or by any other problem.

raftario commented 4 years ago

The double slash is definitely where the issue arises. I'll give this a look.

raftario commented 4 years ago

Nevermind, that's actually an error in your config. You're proxying file upload requests to the root.

Try out with

location /u {
  proxy_pass http://localhost:7500;

  location /f {
    client_max_body_size 10M;
  }
}
luftaquila commented 4 years ago

I tried your config written in readme. But Nginx didn't allow it: nginx: [emerg] location "/f" is outside location "/u" in /etc/nginx/sites-enabled/default:78

I've also tried location /u/f instead of /f, which made /u subdirectory respond 404. I thought nginx passes /u to the filite, so I added rewrite rule:

location /u {
    rewrite ^/u/?(.*)$ /$1 break;
    proxy_pass http://localhost:7500;

    location /u/f {
        client_max_body_size 500M;
    }
}

This make alert on file upload, shows Nginx 405 error html code. This is current status in https://luftaquila.io/u

raftario commented 4 years ago

What is certain is that this is an issue with your NGINX config and not filite itself, so I'm gonna close this issue. I'm not familiar with proxying to subroutes, so can't really help you much with this.

luftaquila commented 4 years ago

So I created a subdomain. When I tried to serve filite at root of the subdomain with exact same config of the readme, it fails with some TypeError. I just gave up and leave behind the file feature. Thank you for your help anyway!

raftario commented 4 years ago

As said earlier this is a problem with your NGINX setup. I'm running two instances fine with the exact same config on my personal server. If nothing else works you can also just move the body size directive to the root location.

location /u {
  proxy_pass http://localhost:7500;
  client_max_body_size 10M;
}