0

i have setup a docker server where i have 4 docker containers 3 have wordpress and the other has contao .. how ever all the wordpress docker-compose.yml files have different domains as always. however when i enter the other domains in the browser they all redirect me back to one of the domains. i have checked the logs and i can see that there is a 301 wc i know is a redirect. so what should i do any one with the same expereince ?

Any help is welcome.

create the docker container that will handle the reverese proxy

docker run --name nginx-proxy --net dockerwp -p 80:80 -p 443:443 -v ~/certs:/etc/nginx/certs -v /etc/nginx/vhost.d -v /usr/share/nginx/html -v /var/run/docker.sock:/tmp/docker.sock:ro --label com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy -d --restart always jwilder/nginx-proxy

create the docker container that will handle the SSL with lets encrypt
docker run --name letsencrypt-nginx-proxy-companion --net dockerwp -v ~/certs:/etc/nginx/certs:rw -v /var/run/docker.sock:/var/run/docker.sock:ro --volumes-from nginx-proxy -d --restart always jrcs/letsencrypt-nginx-proxy-companion

That is what i used to create the reverse proxy and also the ssl encryption.

version: '3'
services:
   db:
     image: mysql:latest
     container_name: letsencrypt-nginx-proxy-companion
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress
     networks:
      - dockerwp

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     expose:
       - "8081"
     restart: always
     environment:
       VIRTUAL_HOST: my.domain.com
       LETSENCRYPT_HOST: my.domain.com
       LETSENCRYPT_EMAIL: mymail@mail.com
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
     volumes:
       - ./wp-app:/var/www/hmtl
     networks:
       - dockernetwork

networks:
  dockernetwork:
    external:
      name: dockernetwork

This is one of the docker-compose.yml files am using and the rest just change domains and ports exposed.

Kabengwa Patrick
  • 339
  • 3
  • 15

1 Answers1

0

Okay i think i finally figured out what my problem was and solved it. In case it helps anyone, please make sure that you have different database configurations for each container in my case i had all the databases containers as bd and when i changed them to different names then everything was okay.

Kabengwa Patrick
  • 339
  • 3
  • 15