Skip to content

Unexpected URL redirects on multiple wordpress sites and domains #962

Description

@jeremysu0131

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:
      - DEFAULT_EMAIL=abc@gmail.com
    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

Activity

  1. coaperator commented on Aug 15, 2022

    @coaperator

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions