413 nginx error on new Plone5.1 install using Ansible Playbook

I've just finished installing the Plone full-stack setup using the Ansible Playbook as documented here:

https://docs.plone.org/external/ansible-playbook/docs/

The Plone versioning information is as follows:

Plone 5.1.2.1 (5112)
CMF 2.2.12
Zope 2.13.27
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15) [GCC 7.3.0]
PIL 4.3.0 (Pillow)

This was installed on Ubuntu Server 18.04.2, with packages brought up to date using apt update and apt upgrade before beginning. nginx is version 1.14.0.

Since installing, all configuration steps taken were done through the Plone interface and were limited to adding an admin user, setting up e-mail, and setting the security settings.

As a next step, I attempted to upload the five themes pointed to here:

I downloaded them from the git sites as zip files and went into the Plone control panel, then Theming, and selected to upload a theme. Upon selecting one of the zip files in the file browser and telling it to upload, I encountered this error:

413 Request Entity Too Large
nginx/1.14.0 (Ubuntu)

Since this appears to be an nginx error, I began by troubleshooting nginx itself. I attempted to add the following setting to /etc/nginx/nginx.conf:

client_max_body_size 100m;

...and not only tried restarting nginx, but rebooting the whole server with no change in behaviour. (Note: I'm testing with the smallest of the theme files, which is less than 4MB.)

I then tried setting it to this:

client_max_body_size 0;

....which is supposed to disable checking entirely.

Further googling hasn't yielded any more help. The only advice I could come up with was to change it in the PHP config also (AFAIK this isn't using PHP, and I don't seem to have PHP installed) or that the setting above is sometimes ignored in nginx versions below 1.07 (I'm using 1.14.0) or over SSL (I'm not using SSL yet).

I'm asking here instead of an nginx forum now because I'm wondering if part of the issue could be that the full-stack install is launching nginx using a config file found elsewhere, but so far my searching has not turned any such thing up.

Anyone know how to solve this? I assume others have set up Plone using the Ansible Playbook and then later tried to upload a theme.

Thanks!

Any chance we could see your nginx configuration file?

I had to use a capital "M" when I ran into that problem. I also had to be sure it was in the right server stanza , as I have two server stanzas, one for SSL and one for non-SSL.

Hi! Thanks! Sorry for not responding sooner; I expected a notification e-mail. :slight_smile: Anyhow, I've tried both uppercase and lowercase M and also tried setting it to 0, which is supposed to disable checking. Here's the file (I haven't altered it from the one created as part of the Playbook other than adding the client_max_body_Size 100M; line):

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        client_max_body_size 100M;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}


#mail {
#       # See sample authentication script at:
#       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#       # auth_http localhost/auth.php;
#       # pop3_capabilities "TOP" "USER";
#       # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#       server {
#               listen     localhost:110;
#               protocol   pop3;
#               proxy      on;
#       }
#}

For the record, I solved it. It turns out that a sub-folder called "sites-enabled" exists which contained a further conf file that redefined the client_max_body_size down to 2M. After changing that setting to match the one above, everything works. This is probably basic knowledge to nginx people, so I apologize for not picking up on that.

For the record: this is a Ubuntu/Debian spefific behavior of nginx which was adapted from apache2 ... the sites-[available|enabled] approach is their best practice ... grep'ing recursively through the config files is always a good idea, then you see in which files the options are set.

Yeah, I've managed Apache sites on Ubuntu before, so as soon as I saw it I had one of those forehead-slapping "of COURSE" moments. :slight_smile: