wp-admin Redirects to Docker Container Name

Question

When I try to reach /wp-admin I am redirected to the container’s name instead of my site URL but cannot see any reason why this is happening. I can log in to /wp-login.php and use the site’s admin pages that way though.

I have checked site_url and home in wp_options which are both correct. Here is my docker-compose.yaml

version: '3'
services:
  nginx:
    image: "nginx"
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /var/log/nginx:/var/log/nginx
      - /opt/nginx/nginx.conf:/etc/nginx/nginx.conf
      - /opt/nginx/sites-enabled:/etc/nginx/sites-enabled
      - /opt/nginx/ssl:/etc/nginx/ssl
    depends_on:
      - "wpcontainer"
    networks:
      - frontend
      - backend
  wpcontainer:
    image: "wordpress"
    networks:
      - frontend
      - backend
    volumes:
      - /opt/wordpress/html:/var/www/html
    depends_on:
      - "wpdatabase"
    environment:
      - WORDPRESS_DB_USER=dbuser
      - WORDPRESS_DB_PASSWORD=dbpass
      - WORDPRESS_DB_NAME=dbname
      - WORDPRESS_DB_HOST=wpdatabase
  wpdatabase:
    image: "mariadb"
    volumes:
      - /opt/wordpress/database:/var/lib/mysql
    networks:
      - backend
    environment:
      - MYSQL_ROOT_PASSWORD=dbroot
      - MYSQL_USER=dbuser
      - MYSQL_PASSWORD=dbpass
      - MYSQL_DATABASE=dbname

networks:
  frontend:
  backend:
   internal: true

The redirection from mysite/wp-admin to wpcontainer/wp-admin happens on both http and https. This is my nginx config which is saved as a file in sites-enabled

server {
 listen 80;
 server_name mywebsite.tld mywebsite.tld.tld www.mywebsite.tld www.mywebsite.tld.tld;
 access_log /var/log/nginx/mywebsite-access.log;
 error_log /var/log/nginx/mywebsite-error.log;
 return 302 https://mywebsite.tld$request_uri;
}

server {
 listen 443 ssl;
 server_name mywebsite.tld www.mywebsite.tld;
 ssl_certificate /etc/nginx/ssl/mywebsite.pem;
 ssl_certificate_key /etc/nginx/ssl/mywebsite.key;

 access_log /var/log/nginx/mywebsite-ssl-access.log;
 error_log /var/log/nginx/mywebsite-ssl-error.log;
 location / {
  proxy_pass http://wpcontainer:80;
 }
}

server {
 listen 443 ssl;
 server_name mywebsite.tld.tld www.mywebsite.tld.tld;
 ssl_certificate /etc/nginx/ssl/mywebsite.pem;
 ssl_certificate_key /etc/nginx/ssl/mywebsite.key;
 return 302 https://mywebsite.tld$request_uri;
}

My question is, how can I prevent the redirect from occurring or make it point to the correct place?

0
, ADeveloper 2 years 2020-01-05T09:41:59-05:00 0 Answers 108 views 0

Leave an answer

Browse
Browse