2

I'm setting up a simple environment on docker with the following stack:

  • nginx as load balance
  • wordpress instance
  • mysql

My simple docker compose file is the following:

nginx:
  build: ../nginx
  links:
    - wordpress:wordpress
  ports:
    - "80:80"
    - "443:443"

wordpress:
  image: wordpress
  ports:
    - "8082:80"
  links:
    - mysqlwp:mysql
  working_dir: /var/www/html
  #volumes:
  #  - wp-content/:/var/www/html/wp-content
  environment:
    WORDPRESS_DB_HOST: mysql
    WORDPRESS_DB_USER: wordpress
    WORDPRESS_DB_PASSWORD: wordpress
    WORDPRESS_DB_NAME: wordpress
mysqlwp:
  image: mysql
  environment:
    MYSQL_ROOT_PASSWORD: root
    MYSQL_DATABASE: wordpress
    MYSQL_USER: wordpress
    MYSQL_PASSWORD: wordpress

nginx is built from base image and configuration is the following:

upstream wploadbalance{
        least_conn;
        server wordpress;
}

server {
       listen 80;
       server_name my.site.com;
       location / {
           proxy_pass http://wploadbalance;
    }
}

Now when I connect to my.site.com I'm correctly redirected to my the wordpress instance but static files are loaded from http://wploadbalance which is not accessible.

For example in my browser console I see something like that:

GET http://wploadbalance/wp-includes/js/wp-util.min.js?ver=4.4 net::ERR_NAME_NOT_RESOLVED

As wploadbalance is not accessible from outside docker container there should by some way to say to wordpress that static files are serverd from my.site.com. Does anyone know how to achieve this?

Paulo Boaventura
  • 1,365
  • 1
  • 9
  • 29
ddelizia
  • 1,571
  • 5
  • 30
  • 54
  • You need to set the WordPress Address (URL) and the Site Address (URL) within the WordPress General Settings. They probably need to be: `http://my.site.com` – Richard Smith Dec 13 '15 at 22:46

1 Answers1

0

Solution:

  1. Log in to the container:

    docker exec -it "name_of_container" bash

  2. Add the following lines to wp-config.php

    define('WP_HOME', 'http://your_domain.com');

    define('WP_SITEURL', 'http://your_domain.com');

Vingtoft
  • 13,368
  • 23
  • 86
  • 135