How to run Docker WordPress through php-fpm on nginx?

Hey there I tried different things but they lead me to the nginx startpage, error 403 or error 404. I’m currently running WordPress without php-fpm but it does not work so good so I want to change it but I only got problems while doing it.

My WordPress Docker-compose (without db):

  wordpress:
    container_name: wordpress
    links:
      - wordpress-db
    depends_on:
      - wordpress-db
    image: wordpress:php7.4-fpm
    ports: 
      - 9000:9000
    restart: always
    volumes:
      - /media/storage/wordpress:/var/www/html
      - .secrets/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
    networks:
      - wordpress
    environment:
      - TZ=Europe/Berlin
    env_file:
      - .secrets/wordpress.env

My nginx compose file:

services:
  nginx:
    restart: always
    container_name: nginx
    image: cptdaydreamer/nginx:latest
    ports:
      - 80:80
      - 443:443
      - 4443:4443
    volumes:
      - /media/storage/log:/var/log/nginx
      - /etc/ssl:/etc/ssl
    external_links:
      - wordpress
    environment:
      - TZ=Europe/Berlin
    build:
      context: /media/storage/nginx
      dockerfile: Dockerfile
    networks:
      - nextcloudpi
      - wordpress
      - matomo
      - php

And now the important part. My nginx configuration:

http {

  server_names_hash_bucket_size 64;

  access_log off;
  error_log /var/log/nginx/error.log;
  
  autoindex_localtime on;
  #more_clear_headers Server;

  ssl_certificate           /etc/ssl/tld.pem;
  ssl_certificate_key       /etc/ssl/tld.key;
  
  gzip            on;
  gzip_min_length 1000;
  gzip_proxied    expired no-cache no-store private auth;
  gzip_types      text/plain text/css text/xml application/javascript application/json application/xml application/rss+xml image/svg+xml;
  gzip_disable    "MSIE [1-6].";
  
  proxy_send_timeout 180s;
  proxy_read_timeout 180s;
  fastcgi_send_timeout 180s;
  fastcgi_read_timeout 180s;

  server {
    listen 80 default_server;
    server_name _;
    server_name_in_redirect off;
    
    location / {
        return 404;
    }
  }

  server {
    listen 80;
    listen [::]:80;
    server_name tld.de cloud.tld.de www.tld.de stats.tld.de;
    return 301 https://$host$request_uri;
  }
  
  # WordPress
  
  server {
    server_name tld.de www.tld.de ts.tld.de;
    
    #access_log /var/log/nginx/wordpress-access.log;
    error_log /var/log/nginx/wordpress-error.log;
    
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    
    client_max_body_size 500m;
    underscores_in_headers on;
    
    root /var/www/html; 
    index index.php;

    location / {
       try_files $uri $uri/ /index.php$is_args$args;
    }

    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;
       fastcgi_param PATH_INFO $fastcgi_path_info;
    }
  }

Errors I get are for example like this: directory index of /var/www/html is forbidden.

If I delete the $uri/ for example I get error 404. What do I need to do to get my instance running? But I’m right that I can use my existing wordpress instance and only the way to access it changes or not?

Source: Docker Questions