Issues with Nginx and Wordpress conection - can't access wp-admin

I have a docker compose that runs three containers: MariaDB, WordPress and Nginx. When I do https: //localhost in Firefox, I get a wordpress sample page, which is what I want. However, when I try to access /localhost/wp-admin/, it just redirects me to the same sample page. When I try to localhost/wp-login.php/ I can access the login page (even though I can’t login with my credentials) and can also access localhost/wp-admin/install.php. This is my Dockerfile and nginx.conf:

FROM    debian:bullseye

EXPOSE  443

RUN     apt-get update \ 
        && apt-get install -y \
            nginx \
            openssl \
            curl \
            wget \
            telnet \
        && apt-get clean \
        && rm -rf /var/lib/apt/lists/*

COPY    conf/nginx.conf /etc/nginx/nginx.conf

RUN     openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
        -keyout /etc/nginx/cert.key \
        -out /etc/nginx/cert.crt \
        -subj "/C=${COUNTRY}/ST=${STATE}/L=${LOCATION}/O=${ORGANIZATION}/CN=${COMMON_NAME}"

CMD ["nginx", "-g", "daemon off;"]
user www-data;
worker_processes auto;

events {
   worker_connections 1024;
}

http {
   include mime.types;
   default_type application/octet-stream;
   sendfile on;
   keepalive_timeout 65;

   server {
       listen 443 ssl;
       listen [::]:443 ssl;

       server_name localhost;

       ssl_protocols TLSv1.2 TLSv1.3;

       ssl_certificate /etc/nginx/cert.crt;
       ssl_certificate_key /etc/nginx/cert.key;

       root /var/www/wordpress;
       index index.php index.html;

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

        location ~ \.php$ {
           fastcgi_pass wordpress:9000;
           fastcgi_index index.php;
           include fastcgi_params;
           fastcgi_param SCRIPT_FILENAME /var/www/wordpress$fastcgi_script_name;
           fastcgi_param PATH_INFO $fastcgi_path_info;
       }

        location ~* \.(jpg|jpeg|gif|css|png|js|ico|xml|svg|woff|woff2|ttf|eot)$ {
           try_files $uri =404;
       }
   }
}

May I ask two questions?

Why not simply use the WordPress image?

And if you want a proxy in front of it, why not simply use nginx-proxy and it’s acme companion with automatic configuration?

That usually saves a lot of hassle.

It really would save a lot of hassle, but this is a school project and we are required to only use Debian’s image and install everything in the container ‘by hand’.
So yeah, I have to struggle with all these conf files and try to figure out why these things aren’t working.

Turns out adding this line to my nginx.conf:

        location /wp-admin {
            try_files $uri $uri/ /wp-admin/index.php?$args;
        }

Solved my issue.