PrivateBin / docker-nginx-fpm-alpine

PrivateBin docker image based on Nginx, php-fpm & Alpine Linux stack
https://hub.docker.com/r/privatebin/nginx-fpm-alpine/
147 stars 57 forks source link

Wrong size limit error #151

Closed Mawarii closed 10 months ago

Mawarii commented 1 year ago

I installed the docker version some days ago and if I reach the size limit with files I only get this kind of error: Could not create paste: server error or not responding. Is this intended? Its kinda misleading. As far as I saw on other screenshots there should be a size limit error.

Or did I do something wrong in the deployment? I did not change anything around the size limit, so its default.

elrido commented 1 year ago

The API does include a special error message, when the size is too large, but when the size is larger than the limits configured in the webserver or PHP runtime it won't actually reach the API code and you get that generic error 500 from the server. To illustrate the various layers at play here:

  ┌──────────────┐
  │ POST request │
  └──────┬───────┘
         │
         │
         │
   ┌─────▼──────┐
   │ nginx POST │
   │   limit    ├─────────────────┐
   └─────┬──────┘                 │
         │             ┌──────────▼─────────────┐
         │             │ HTTP response code 500 │
         │             └──────────▲─────────────┘
   ┌─────▼───────┐                │
   │ PHP request ├────────────────┘
   │    limit    │
   └─────┬───────┘
         │
         │
         │
   ┌─────▼──────┐      ┌───────────────────────────┐
   │ PrivateBin │      │ message "Paste is limited │
   │ size limit ├──────► to %s of encrypted data." │
   └─────┬──────┘      └───────────────────────────┘
         │
         │
         │
         │
┌────────▼──────────┐
│ upload suceessful │
└───────────────────┘

With the container images current configuration, the PHP and nginx limits are around 15 MiB and the PrivateBin default configuration is at 10 MiB. That means you will get the error 500 from the nginx or PHP-fpm layers above a size of 15 MiB and the formatted message between 10 and 15 MiB.

If you want to adjust these limits, please see:

Caveat: Since we encode the payload as base64, which increases the size by about 33%, but after zlib compressing and encrypting the message, the actual payloads size may be below or quite a bit above these limits, depending on how well it compresses. For example an image would not compress well and need to be below 7 MiB to fit the 10 MiB limit, but a large log file with lots of repeated messages may still upload at a 100 MiB, if it compresses down below the threshold.

Mawarii commented 1 year ago

Holy shit. Thank you so much for that awesome answer. I appreciate that a lot. I will head into that. Thank you so much again :)

rugk commented 10 months ago

So as it seems this question has been answered and I thus close this issue. If anyone has further questions on that topic, feel free to comment here, again.