Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nginx - client_max_body_size has no effect with ssl configured

When I set client_max_body_size 30m; without ssl everything works (files up to 30MB are accepted). However when I switch to ssl it completely ignores this directive.

My configuration looks like (/etx/nginx/conf.d/my-sites.com.conf):

server {
  listen 443 ssl;
  server_name my-sites.com;
  ssl_certificate /etc/nginx/ssl/my-sites.com/uni_my-sites.com.crt;
  ssl_certificate_key /etc/nginx/ssl/my-sites.com/my-sites.com.key;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

  client_max_body_size 30m;

  location / {
    proxy_pass http://my-backend.com;
    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-Proto $scheme;
  }
}

I found several suggestions here nginx - client_max_body_size has no effect but nothing worked. I've tries to use diferent nginx versions, I set client_max_body_size for all blocks: http, server, location but nothing works.

I've also searched if it is an nginx bug with no results.

Is there any solution I can overcome the problem or am I forced to use non-ssl connection? Any suggestions are welcomed.

My configuration is:

  • AWS EC2 nano instance
  • Nginx in docker (latest stable - 1.10.1)
  • Only one virtual host on single IP address

Difference from this question nginx - client_max_body_size has no effect: this question is related to ssl

Edit: I've created an issue in nginx wiki https://trac.nginx.org/nginx/ticket/1076#ticket

like image 754
kuceram Avatar asked Nov 20 '22 18:11

kuceram


1 Answers

I finally found the cause of this problem. Nginx works correctly, however I routed requests to AWS Elastic Beanstalk which uses nginx internally to route requests to inside Docker container.

So the misconfiguration was on the side of AWS Elastic Beanstalk. Configuring the AWS fixed the problem.

like image 111
kuceram Avatar answered Nov 23 '22 22:11

kuceram