12

I've deployed an on prem instance of Nexus OSS, that is reached behind a Nginx reverse proxy.

On any attempt to push docker images to a repo created on the Nexus registry I'm bumping into a 413 Request Entity Too Large in the middle of the push.

The nginx.conf file is looking like so:

http {
    client_max_body_size 0;
    upstream nexus_docker {
        server nexus:1800;
    } 
    server {
        server_name nexus.services.loc;
        location / {
            proxy_pass http://nexus_docker/;
            proxy_set_header Host $http_post;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        } 
    } 
} 

The nginx is deployed using docker, and I've successfully logged in to it using docker login. I've tried multiple other flags, such as the chunkin and such. But nothing seems to work.

Boaz Berman
  • 230
  • 4
  • 13

2 Answers2

15

That's due to your server block having a default value for client_max_body_size of around 1MB in size when unset.

To resolve this, you will need to add the following line to your server block:

# Unlimit large file uploads to avoid "413 Request Entity Too Large" error
client_max_body_size 0;

http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size

sktan
  • 1,049
  • 6
  • 14
  • I've attempted it already, and also added it to the location block. It still does not work. – Boaz Berman Jan 07 '19 at 15:24
  • 1
    Try putting it in the "server" section: https://help.sonatype.com/display/NXRM3/Run+Behind+a+Reverse+Proxy#RunBehindaReverseProxy-nginx – rseddon Jan 07 '19 at 18:39
6

As it turns out, the linux distro running the containered nginx server was itself running a variation of nginx for any incoming request.

Once we set the client_max_body_size to 0 on the nginx configuration file which the OS ran, it worked.

Boaz Berman
  • 230
  • 4
  • 13
  • what is the meaning of "OS level". could your explain more about this. thanks – rezshar Aug 11 '21 at 14:00
  • 1
    @rezshar well I'm not an expert on why it was there, but there was an Nginx (which the OS took care of) that proxied all requests coming to docker containers on that server. That is why I had to change that Nginx proxy's configuration to make it work. – Boaz Berman Aug 12 '21 at 13:55