acme-companion icon indicating copy to clipboard operation
acme-companion copied to clipboard

Unexpected URL redirects on multiple wordpress sites and domains

Open jeremysu0131 opened this issue 3 years ago • 1 comments
trafficstars

Bug description

I have two wordpress container and two domain.

abc.com -> container 1 123.com -> container 2

When I only running the container 1 with domain abc.com, everything works find. And then I start running the container 2 with domain 123.com, the problem happend.

When I access the domain abc.com/contact, it will redirect to 123.com/contact occasionally and vice versa. I also check the network in Chrome developer tool, it will show 301 Moved Permanently and redirect to other domain.

nginx-proxy's Docker configuration

Both nginx-proxy and acme-companion version are latest.

version: '2'

services:
  nginx-proxy:
    image: nginxproxy/nginx-proxy
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - conf:/etc/nginx/conf.d
      - vhost:/etc/nginx/vhost.d
      - html:/usr/share/nginx/html
      - certs:/etc/nginx/certs:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
    networks:
      - network

  acme-companion:
    image: nginxproxy/acme-companion
    restart: unless-stopped
    environment:
      - [email protected]
    volumes_from:
      - nginx-proxy
    volumes:
      - acme:/etc/acme.sh
      - certs:/etc/nginx/certs:rw
      - /var/run/docker.sock:/var/run/docker.sock:ro
    networks:
      - network

networks:
  network:
    external:
      name: nginx-proxy_network

volumes:
  conf:
  vhost:
  html:
  certs:
  acme:

Wordpress Docker configuration

version: '3'

services:
  wp:
    image: wordpress:php7.3-fpm
    volumes:
      - ./config/php.conf.ini:/usr/local/etc/php/conf.d/conf.ini
      - ./wp-app:/var/www/html
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_NAME: "${DB_NAME}"
      WORDPRESS_DB_USER: root
      WORDPRESS_DB_PASSWORD: "${DB_ROOT_PASSWORD}"
    depends_on:
      - db
    links:
      - db
    restart: always

  nginx:
    image: nginx:latest
    volumes:
      - ./nginx:/etc/nginx/conf.d
      - ./logs/nginx:/var/log/nginx
      - ./wp-app:/var/www/html
    depends_on:
      - wp
    restart: always
    environment:
      - VIRTUAL_HOST=abc.com #Container 2 is `123.com`
      - VIRTUAL_PORT=80
      - LETSENCRYPT_HOST=abc.com

networks:
  default:
    external: true
    name: nginx-proxy_network

jeremysu0131 avatar Jul 21 '22 15:07 jeremysu0131

you can't run 2 instances of nginx, that won't work move the settings from the second app to nginx-proxy's Docker configuration

coaperator avatar Aug 15 '22 20:08 coaperator