title: Docker + Wordpress + Nginx 404 images
body: <p>I've set up a docker-compose with wordpress, nginx and mysql containers.</p>
  <p>Everything is working fine besides the uploading of images. When I upload images they don't get saved in either of the container's /uploads folder, and just show a blank image on wp-admin.</p>
  <p><a href="https://i.stack.imgur.com/9pUMD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9pUMD.png" alt="blank image" /></a></p>
  <p><a href="https://i.stack.imgur.com/yqJpY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yqJpY.png" alt="" /></a></p>
  <p>If I try to access the image <a href="http://wp-content/uploads/2021/11/ian-dooley-DJ7bWa-Gwks-unsplash1.jpg" rel="nofollow noreferrer">url</a> directly it returns 404.</p>
  <p><a href="https://i.stack.imgur.com/tgmcD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tgmcD.png" alt="404" /></a></p>
  <p>I've found 3 (<a href="https://stackoverflow.com/questions/39105398/error-403-with-nginx-and-images-uploaded-with-wordpress">post 1</a>, <a href="https://stackoverflow.com/questions/21252727/wordpress-image-carousel-showing-blank-images">post 2</a> &amp; <a href="https://stackoverflow.com/questions/69815954/blank-images-in-wordpress">post 3</a>) related posts, but none of them gave me any insights to this problem.</p>
  <p>This is my docker-compose:</p>
  <pre><code>version: '3.1'
  
  services:
    wordpress:
      image: wordpress:fpm-alpine
      depends_on:
        - db
      restart: always
      env_file: 
      - .env
      ports:
        - 9000:9000
      environment:
        WORDPRESS_DB_HOST: db
        WORDPRESS_DB_USER: ${DB_USER}
        WORDPRESS_DB_PASSWORD: ${DB_PASSWORD}
        WORDPRESS_DB_NAME: ${DB}
        WORDPRESS_DEBUG: ${DEBUG}
        WORDPRESS_DEBUG_DISPLAY: ${DEBUG}
        WORDPRESS_DEBUG_LOG: ${DEBUG}
      volumes:
        - ./theme-folder:/var/www/html/wp-content/themes/theme-folder
  
    db:
      image: mysql:5.7
      restart: always
      env_file: 
      - .env
      environment:
        MYSQL_DATABASE: ${DB}
        MYSQL_USER: ${DB_USER}
        MYSQL_PASSWORD: ${DB_PASSWORD}
        MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
      volumes:
        - db:/var/lib/mysql
  
    webserver:
      image: nginx:alpine
      depends_on:
        - wordpress
      ports:
        - 8080:80
        - 443:443
      volumes:
        - ./nginx-conf:/etc/nginx/conf.d
        - wordpress:/var/www/html
        - ./theme-folder:/var/www/html/wp-content/themes/theme-folder
        - ./pem/fullchain.pem:/etc/letsencrypt/live/website/fullchain.pem
        - ./pem/privkey.pem:/etc/letsencrypt/live/website/privkey.pem
  
  volumes:
    wordpress:
    db:
  </code></pre>
  <p>This is my nginx.conf:</p>
  <pre><code>server {
      listen 80;
      listen [::]:80;
      server_name website;
      root /var/www/html;
      index index.php index.html index.htm;
  
      location ~ \.php$ {
              try_files $uri =404;
              fastcgi_split_path_info ^(.+\.php)(/.+)$;
              fastcgi_pass wordpress:9000;
              fastcgi_index index.php;
              include fastcgi_params;
              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      }
  
      location / {
              rewrite ^ https://$host$request_uri? permanent;
      }
  }
  
  server {
      listen 443 ssl;
      listen [::]:443 ssl;
      server_name website;
      root /var/www/html;
      index index.php index.html index.htm;
  
      ssl_certificate /etc/letsencrypt/live/website/fullchain.pem;
      ssl_certificate_key /etc/letsencrypt/live/website/privkey.pem;
  
      location ~ \.php$ {
              try_files $uri =404;
              fastcgi_split_path_info ^(.+\.php)(/.+)$;
              fastcgi_pass wordpress:9000;
              fastcgi_index index.php;
              include fastcgi_params;
              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      }
  }
  </code></pre>
  <p>Really appreciate any insights, I've been stuck here for days now.</p>
  <h2>Updates</h2>
  <p>Tried tailing docker logs, but didn't help much.</p>
  <p><a href="https://i.stack.imgur.com/GMSgC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GMSgC.png" alt="wordpress container logs" /></a></p>
  <p>Also, tried adding this to my nginx.conf:</p>
  <pre><code>location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
      expires max;
      log_not_found off;
  }
  </code></pre>