Skip to content

loopback requests fail when 'site_url' points to localhost:xxxx #179

@EvanShaw

Description

@EvanShaw

First of all, thank you for this great repo! I use the images everyday for local development.

  • OS: Ubuntu Linux 18.04
  • docker version: 19.03.13

Overview

In a local environment, where an arbitrary port is forwarded to the host machine (eg. -p 9000:80), requests to site_url, home_url, etc. that are invoked from within the container via wp_remote_post, cURL, etc. do not work since Apache only listens on ports 80 and 443. Because of this, things like wp-cron, which in this case would send a request to localhost:9000, fail.

At the moment, I'm getting around this by making Apache also listen on the published port, which I pass as a Docker environment variable to be used in my custom entrypoint:

sudo sh -c "echo \"Listen ${DOCKER_CONTAINER_PORT}\" >> /etc/apache2/ports.conf"
sudo sed -i "s/VirtualHost \*:80/VirtualHost \*:80 \*:${DOCKER_CONTAINER_PORT}/g" /etc/apache2/sites-enabled/000-default.conf

This is probably not an issue for people using the images in production. It's not really a bug, I guess, but I thought I would let you all know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions