Docker compose redirects port 9085 to port 80

Docker compose redirects port 9085 to port 80, unless I specify an additional path after the address, for example index.php.


version: "3.8"
    container_name: web-nginx
    build: ./docker/nginx
    command: nginx -g "daemon off;"
      - web-php
      - "9085:80"
      - "4444:443"
      - ./logs/nginx:/var/log/nginx
      - ./src:/var/www/html
    container_name: web-php
    build: ./docker/php
      - "9001:9000"
      - ./src:/var/www/html
    working_dir: /var/www/html
    image: mysql:8.0.32
    container_name: web-mysql
      - ./env/mysql.env
      - "3307:3306"
      - ./database/mysql:/var/lib/mysql
    command: '--default-authentication-plugin=mysql_native_password'

default.conf (nginx):

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html;

        # Add index.php to the list if you are using PHP
        index index.php;
        # index.html index.htm index.nginx-debian.html;

        server_name mysite;
        location / {
        # pass PHP scripts to FastCGI server
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass web-php:9000;
                fastcgi_index index.php;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param PATH_INFO $fastcgi_path_info;
        #location ~ /\.ht {
        #       deny all;
        location = /favicon.ico { log_not_found off; access_log off; }
        location = /robots.txt { log_not_found off; access_log off; allow all; }
        location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
                expires max;
                log_not_found off;
        client_max_body_size 1024M;



FROM nginx:1.25.4

ADD default.conf /etc/nginx/conf.d/default.conf


FROM php:8.2-fpm

RUN apt-get update
RUN docker-php-ext-install pdo pdo_mysql mysqli

After creating the images, everything starts up normally.
docker ps:

ttsv@docker:~/wp3$ docker compose ps
WARN[0000] /home/ttsv/wp3/docker-compose.yaml: `version` is obsolete
NAME        IMAGE           COMMAND                  SERVICE     CREATED         STATUS         PORTS
web-mysql   mysql:8.0.32    "docker-entrypoint.s…"   web-mysql   5 seconds ago   Up 4 seconds   33060/tcp,>3306/tcp, :::3307->3306/tcp
web-nginx   wp3-web-nginx   "/docker-entrypoint.…"   web-nginx   5 seconds ago   Up 4 seconds>80/tcp, :::9085->80/tcp,>443/tcp, :::4444->443/tcp
web-php     wp3-web-php     "docker-php-entrypoi…"   web-php     5 seconds ago   Up 4 seconds>9000/tcp, :::9001->9000/tcp

However, when I try to access the container at, it redirects me to, where I have another Docker web running on port 80. If I stop this container, it still tries to redirect to it. However, when I add a specific path, for example, then it doesn’t redirect and stays at the current address and port. Does anyone have an idea why this behavior is happening?


ttsv@docker:~/wp3$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:        12
Codename:       bookworm

Docker version:

ttsv@docker:~/wp3$ docker version
Client: Docker Engine - Community
 Version:           26.0.0
 API version:       1.45
 Go version:        go1.21.8
 Git commit:        2ae903e
 Built:             Wed Mar 20 15:18:01 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
  Version:          26.0.0
  API version:      1.45 (minimum version 1.24)
  Go version:       go1.21.8
  Git commit:       8b79278
  Built:            Wed Mar 20 15:18:01 2024
  OS/Arch:          linux/amd64
  Experimental:     false
  Version:          1.6.28
  GitCommit:        ae07eda36dd25f8a1b98dfbf587313b99c0190bb
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
  Version:          0.19.0
  GitCommit:        de40ad0

I solved the issue by adding the following lines to nginx:

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

I added them because apparently WordPress is making some internal redirects; I have no idea why. Here’s how I caught them:

ttsv@docker:~/wp3$ curl -v
*   Trying
* Connected to ( port 9085 (#0)
> GET /wp-admin/ HTTP/1.1
> Host:
> User-Agent: curl/7.88.1
> Accept: */*
< HTTP/1.1 302 Found
< Server: nginx/1.25.4
< Date: Fri, 12 Apr 2024 12:54:32 GMT
< Content-Type: text/html; charset=UTF-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< X-Powered-By: PHP/8.2.18
< Expires: Wed, 11 Jan 1984 05:00:00 GMT
< Cache-Control: no-cache, must-revalidate, max-age=0
< X-Redirect-By: WordPress
< Location:
* Connection #0 to host left intact