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;
}
}
}