Issues increasing docker-wordpress container filesize limit

Hi all,

I’ve been working on testing migrating a previous install of wordpress to a docker container in a virtual environment in preparation to possibly do that to the live version of the site. I’m trying to just install the Updraft Plus plugin (if you aren’t familiar, its a widely used backup/migration solution for wordpress), and add the generated backup files to the virtual containerized wordpress instance. Installing the plugin works, but trying to drag and drop the files isn’t. I’m getting the following pop-up:

Upload error (code -200) : HTTP Error. (HTTP code: 413)
The file failed to upload. Please check the following:

  • Any settings in your .htaccess or web.config file that affects the maximum upload or post size.
  • The available memory on the server.
  • That you are attempting to upload a zip file previously created by UpdraftPlus.

Further information may be found in the browser JavaScript console, and the server PHP error logs.

I’ve looked up the issue elsewhere and found a number of possible solutions, most involving volumes of modified files (dunno if that’s the right way of saying it). Here’s my docker-compose (which is mostly adapted from this Digital Ocean tutorial:

version: '3'

    image: mysql:8.0
    container_name: db
    restart: unless-stopped
    env_file: .env
      - MYSQL_DATABASE=wordpress
      - dbdata:/var/lib/mysql
    command: '--default-authentication-plugin=mysql_native_password'
      - app-network

      - db
    image: wordpress:5.8.3-fpm-alpine
    container_name: wordpress
    restart: unless-stopped
    env_file: .env
      - WORDPRESS_DB_HOST=db:3306
      - WORDPRESS_DB_NAME=wordpress
      - wordpress:/var/www/html
      - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
      - ./.htaccess:/var/html/www/.htaccess
      - app-network

      - wordpress
    image: nginx:1.21.5-alpine
    container_name: webserver
    restart: unless-stopped
      - "80:80"
      - wordpress:/var/www/html
      - ./nginx-conf:/etc/nginx/conf.d
      #- certbot-etc:/etc/letsencrypt
      - app-network


    driver: bridge

The upload.ini:

file_uploads = On
memory_limit = 500M
upload_max_filesize = 100M
post_max_size = 250M
max_execution_time = 600

The .htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

php_value upload_max_filesize 500M
php_value post_max_size 500M

So yeah, I’m trying to increase the filesize limit (the biggest file I’m trying to upload to the wordpress is 20 megabytes). Has anyone run into this and/or can help? I’d really appreciate it.

You have NginX not Apache HTTPD. htaccess files for HTTPD servers. As far as I know nginx doesn’t support it. You have to increase the limits in the nginx site configuration

Oh, I thought from reading the solutions that I found, that wordpress had an htaccess file? For instance, after doing further research, this s/o solution seems to be saying to go to the Wordpress container’s htaccess file and changing it:

It’s even included in the second step in a solution assuming the setup includes the jwilder nginx container…

Wordpress may have an htaccess file, but the PHP application will not use it. htaccess files are for Apache HTTPD servers. The solution you found uses an NginX proxy in front of Apache HTTPD. In that case there are three containers that needs configuration.

  • PHP container in php.ini (or php-fpm.conf)
  • Apache HTTPD in httpd.conf (requires server reload) or .htaccess (doesn’t require server restart)
  • NginX proxy.

If you don’t have nginx proxy, you don’t need to configure that, but instead you need to configure NginX in the same docker compose project the same way as you would configure NginX proxy. If you have done that, then it should work.

Some additional notes:

  • htaccess can be used with Apache HTTPD only. Even if you had Apache HTTPD, in case of Docker containers it is a good practice to configure the HTTPD server by changing the server configuration instead of using htaccess for performance and maybe security reasons.
  • Even if you had Apache HTTPD instead of NginX, you could not change the php settings in htaccess because it works only if you use PHP as an HTTPD module, but you use PHP FPM in the wordpress container.
  • It is also possible that your file size limit is in your wordpress and not in PHP or nginx. I don’t remember the default limits if it has any.
1 Like