<p>This was so simple I've been kicking myself ever since I figured out what was wrong.</p>
<p>In the WP stack docker compose file this line was correct, but missing the 'www'.</p>
<pre><code>extra_hosts:
      - &quot;www.my-domain-name.com:192.168.80.2&quot;
</code></pre>
<p>In my WordPress setup the site URL included the www. So I was right to point the domain name to the IP of the Nginx container, but not including the full URL as specified in WP was causing the issue.</p>
<p>For anybody experiencing WP Site Health issues when using Docker, Nginx the solution is to use the &quot;extra_hosts&quot; directive in the wordpress container setup and point the IP of the Nginx container to the WordPress site URL.</p>

CC BY-SA 4.0
2020-12-10T20:49:39.893Z
2020-12-10T22:42:46.187Z
2020-12-10T22:42:46.187Z
mtibbits
<p>I am trying to setup a production environment for multiple WordPress sites using Docker, Nginx reverse proxy, and Let's Encrypt.</p>
<p>I have 3 containers for the proxy group using the jwilder/docker-gen, jwilder/nginx-proxy, and jrcs/letsencrypt-nginx-proxy-companion images.</p>
<p>I also have separate containers for mysql and WordPress.</p>
<p>Everything runs ok and the site loads. However, I am getting the following Site Health Errors in WordPress:</p>
<blockquote>
<p>The REST API request failed due to an error. Error: cURL error 28:
Connection timed out after 10000 milliseconds (http_request_failed)</p>
</blockquote>
<blockquote>
<p>The loopback request to your site failed, this means features relying
on them are not currently working as expected. Error: cURL error 28:
Connection timed out after 10001 milliseconds (http_request_failed)</p>
</blockquote>
<blockquote>
<p>Background updates ensure that WordPress can auto-update if a security
update is released for the version you are currently using.</p>
<p>Warning Could not confirm that the wp_version_check() filter is
available</p>
</blockquote>
<p>I have confirmed that cURL is working within the WordPress container and also that all containers are on the same docker network.</p>
<p>I have tried disabling all plugins in WordPress and using default theme (twentytwenty).</p>
<p>I am able to update plugins and themes.</p>
<p>I have updated my php settings in the WP container so that max_execution_time = 600 and memory_limit = 1024M.</p>
<p>This same site runs on a LAMP stack and all Site Health tests pass.</p>
<p>I will also mention that the site also seems slower to respond when running in the Docker container.</p>
<p>I am thinking that this must have something to do with Nginx, but cannot figure out what it could be. Any help would be greatly appreciated.</p>
<p>Included are my docker-compose configurations.</p>
<p>For Nginx:</p>
<pre><code>
services:
  nginx:
    image: jwilder/nginx-proxy
    container_name: nginx
    restart: always
    labels:
      com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: 'true'
    ports:
      - 80:80
      - 443:443
    # environment: 
    #   - VIRTUAL_PROTO=https
    #   - VIRTUAL_PORT=443  
    volumes:      
      - /srv/nginx/data/conf.d:/etc/nginx/conf.d
      - /srv/nginx/data/vhost.d:/etc/nginx/vhost.d
      - /srv/nginx/data/html:/usr/share/nginx/html
      - /srv/nginx/data/certs:/etc/nginx/certs:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
    networks: 
      - proxy

  dockergen:
    image: jwilder/docker-gen
    container_name: dockergen
    command: -notify-sighup nginx -watch /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf    
    volumes:
      - /srv/nginx/data/conf.d:/etc/nginx/conf.d
      - /srv/nginx/data/vhost.d:/etc/nginx/vhost.d
      - /srv/nginx/data/html:/usr/share/nginx/html
      - /srv/nginx/data/certs:/etc/nginx/certs:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - ./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro
    networks:
      - proxy
  
  letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    container_name: letsencrypt
    depends_on:
      - nginx
      - dockergen
    environment:
      NGINX_PROXY_CONTAINER: nginx
      NGINX_DOCKER_GEN_CONTAINER: dockergen
    volumes:
      - /srv/nginx/data/conf.d:/etc/nginx/conf.d
      - /srv/nginx/data/vhost.d:/etc/nginx/vhost.d
      - /srv/nginx/data/html:/usr/share/nginx/html
      - /srv/nginx/data/certs:/etc/nginx/certs:rw     
      - /var/run/docker.sock:/var/run/docker.sock:ro
    networks: 
      - proxy

networks:
  proxy: 
    driver: bridge
</code></pre>
<p>For WP:</p>
<pre><code>
services:

  db:
    container_name: $DB_CONTAINER
    image: mysql:5.7
    restart: always
    volumes:
      - ./db_data:/var/lib/mysql
    environment:
      #MYSQL_RANDOM_ROOT_PASSWORD: 1
      MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD
      MYSQL_DATABASE: $DB_NAME
      MYSQL_USER: $DB_USER
      MYSQL_PASSWORD: $DB_PASSWORD

  wp:
    container_name: $WP_CONTAINER
    image: wordpress:latest
    depends_on:
      - db
    expose: 
      - 80
    restart: always
    extra_hosts:
      - &quot;my-domain-name.ca:192.168.80.2&quot;
    volumes:
      #- ./wp-config.php:/var/www/html/wp-config.php:rw
      - ./wp-content:/var/www/html/wp-content:rw
      - ./config/php-config.ini:/usr/local/etc/php/conf.d/php-config.ini
    environment:
      WORDPRESS_DB_HOST: $DB_CONTAINER
      WORDPRESS_DB_NAME: $DB_NAME
      WORDPRESS_DB_USER: $DB_USER
      WORDPRESS_DB_PASSWORD: $DB_PASSWORD
      WORDPRESS_TABLE_PREFIX: $WP_TABLE_PREFIX
      VIRTUAL_HOST: $VIRTUAL_HOST
      VIRTUAL_PORT: $VIRTUAL_PORT
      LETSENCRYPT_HOST: $LETSENCRYPT_HOST
      LETSENCRYPT_EMAIL: $LETSENCRYPT_EMAIL
      WORDPRESS_CONFIG_EXTRA: |
        define('ALTERNATE_WP_CRON', true);
        define('FORCE_SSL_ADMIN', true);

networks:
  default:
    external:
      name: nginx_proxy
</code></pre>

<docker><nginx>
WordPress Site Health errors when using Docker and Nginx
mtibbits
# WordPress Site Health errors when using Docker and Nginx

(Asked by: username_0 on 2020-12-10)

I am trying to setup a production environment for multiple WordPress sites using Docker, Nginx reverse proxy, and Let's Encrypt.
I have 3 containers for the proxy group using the jwilder/docker-gen, jwilder/nginx-proxy, and jrcs/letsencrypt-nginx-proxy-companion images.
I also have separate containers for mysql and WordPress.
Everything runs ok and the site loads. However, I am getting the following Site Health Errors in WordPress:

The REST API request failed due to an error. Error: cURL error 28:
Connection timed out after 10000 milliseconds (http_request_failed)


The loopback request to your site failed, this means features relying
on them are not currently working as expected. Error: cURL error 28:
Connection timed out after 10001 milliseconds (http_request_failed)


Background updates ensure that WordPress can auto-update if a security
update is released for the version you are currently using.
Warning Could not confirm that the wp_version_check() filter is
available

I have confirmed that cURL is working within the WordPress container and also that all containers are on the same docker network.
I have tried disabling all plugins in WordPress and using default theme (twentytwenty).
I am able to update plugins and themes.
I have updated my php settings in the WP container so that max_execution_time = 600 and memory_limit = 1024M.
This same site runs on a LAMP stack and all Site Health tests pass.
I will also mention that the site also seems slower to respond when running in the Docker container.
I am thinking that this must have something to do with Nginx, but cannot figure out what it could be. Any help would be greatly appreciated.
Included are my docker-compose configurations.
For Nginx:

services:
  nginx:
    image: jwilder/nginx-proxy
    container_name: nginx
    restart: always
    labels:
      com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: 'true'
    ports:
      - 80:80
      - 443:443
    # environment: 
    #   - VIRTUAL_PROTO=https
    #   - VIRTUAL_PORT=443  
    volumes:      
      - /srv/nginx/data/conf.d:/etc/nginx/conf.d
      - /srv/nginx/data/vhost.d:/etc/nginx/vhost.d
      - /srv/nginx/data/html:/usr/share/nginx/html
      - /srv/nginx/data/certs:/etc/nginx/certs:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
    networks: 
      - proxy

  dockergen:
    image: jwilder/docker-gen
    container_name: dockergen
    command: -notify-sighup nginx -watch /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf    
    volumes:
      - /srv/nginx/data/conf.d:/etc/nginx/conf.d
      - /srv/nginx/data/vhost.d:/etc/nginx/vhost.d
      - /srv/nginx/data/html:/usr/share/nginx/html
      - /srv/nginx/data/certs:/etc/nginx/certs:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - ./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro
    networks:
      - proxy
  
  letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    container_name: letsencrypt
    depends_on:
      - nginx
      - dockergen
    environment:
      NGINX_PROXY_CONTAINER: nginx
      NGINX_DOCKER_GEN_CONTAINER: dockergen
    volumes:
      - /srv/nginx/data/conf.d:/etc/nginx/conf.d
      - /srv/nginx/data/vhost.d:/etc/nginx/vhost.d
      - /srv/nginx/data/html:/usr/share/nginx/html
      - /srv/nginx/data/certs:/etc/nginx/certs:rw     
      - /var/run/docker.sock:/var/run/docker.sock:ro
    networks: 
      - proxy

networks:
  proxy: 
    driver: bridge

For WP:

services:

  db:
    container_name: $DB_CONTAINER
    image: mysql:5.7
    restart: always
    volumes:
      - ./db_data:/var/lib/mysql
    environment:
      #MYSQL_RANDOM_ROOT_PASSWORD: 1
      MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD
      MYSQL_DATABASE: $DB_NAME
      MYSQL_USER: $DB_USER
      MYSQL_PASSWORD: $DB_PASSWORD

  wp:
    container_name: $WP_CONTAINER
    image: wordpress:latest
    depends_on:
      - db
    expose: 
      - 80
    restart: always
    extra_hosts:
      - "my-domain-name.ca:192.168.80.2"
    volumes:
      #- ./wp-config.php:/var/www/html/wp-config.php:rw
      - ./wp-content:/var/www/html/wp-content:rw
      - ./config/php-config.ini:/usr/local/etc/php/conf.d/php-config.ini
    environment:
      WORDPRESS_DB_HOST: $DB_CONTAINER
      WORDPRESS_DB_NAME: $DB_NAME
      WORDPRESS_DB_USER: $DB_USER
      WORDPRESS_DB_PASSWORD: $DB_PASSWORD
      WORDPRESS_TABLE_PREFIX: $WP_TABLE_PREFIX
      VIRTUAL_HOST: $VIRTUAL_HOST
      VIRTUAL_PORT: $VIRTUAL_PORT
      LETSENCRYPT_HOST: $LETSENCRYPT_HOST
      LETSENCRYPT_EMAIL: $LETSENCRYPT_EMAIL
      WORDPRESS_CONFIG_EXTRA: |
        define('ALTERNATE_WP_CRON', true);
        define('FORCE_SSL_ADMIN', true);

networks:
  default:
    external:
      name: nginx_proxy

**Tags:** docker, nginx


---

## 1 answers

### Answer by username_0 on 2020-12-10. Score: 1

This was so simple I've been kicking myself ever since I figured out what was wrong.
In the WP stack docker compose file this line was correct, but missing the 'www'.
extra_hosts:
      - "www.my-domain-name.com:192.168.80.2"

In my WordPress setup the site URL included the www. So I was right to point the domain name to the IP of the Nginx container, but not including the full URL as specified in WP was causing the issue.
For anybody experiencing WP Site Health issues when using Docker, Nginx the solution is to use the "extra_hosts" directive in the wordpress container setup and point the IP of the Nginx container to the WordPress site URL.


---

