wordpresswp-admin

How to connect a Wordpress site to an existing Wordpress site domain with an extension using Docker and NginX? And correctly redirect wp-admin


I have an existing WordPress site running in a docker container, I have directed the traffic using a proxy pass in NginX (docker) to the particular port.

location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-NginX-Proxy true;
        proxy_set_header Host $http_host;
        proxy_pass http://IP:8000;
    }

For example https://domain/ connects to the above mentioned proxy pass which is my current wordpress site

location /new {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-NginX-Proxy true;
        proxy_set_header Host $http_host;
        proxy_pass http://IP:8001;
    }

Above is the new proxy pass which I added in order to connect to the new WordPress site running on (Container) Port 8001

https://domain/new redirects me to the new wordpress site

The redirection occurs successfully, but the when i try to log into the admin portal of the new WordPress site https://domain/new/wp-admin,

It redirects to the old WordPress site wp-admin (https://domain/wp-admin). After checking the NginX configuration I can confirm that no redirection is happening from the NginX side.

And the volume mapping changes are also working as expected

Is there a file in the wp-contents or some DB configuration that I am missing? which redirects the new Wordpress Site request to the old one.

Note : It happened even when I commented out the old WordPress site proxy pass. Giving a 404


Solution

  • I was able to finally solve the mentioned issue, it was not a Docker or NginX issue.

    There is no need to build a new docker container. What I had to do was create a sub-directory within the existing WordPress content directory.

    And provide the relevant Database information and credential in the docker-compose file (creating new variable names and adding them in the wp-config.php file in the new sub directory).

    Then the https://domain/new starts working and https://domain/new/wp-admin works as expected.