Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected URL redirects on multiple wordpress sites and domains #962

Open
jeremysu0131 opened this issue Jul 21, 2022 · 1 comment
Open

Comments

@jeremysu0131
Copy link

jeremysu0131 commented Jul 21, 2022

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
@coaperator
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants