docker-library / docs

Documentation for Docker Official Images in docker-library
https://github.com/docker-library/official-images
MIT License
5.07k stars 2.2k forks source link

Add documentation for fix for loopback problem when port is mapped #2262

Open visionm45 opened 1 year ago

visionm45 commented 1 year ago

When the ports are mapped from the container's port 80 to another port wordpress has 2 problems:

"The REST API encountered an error" "Your site could not complete a loopback request"

This has hindered me in development in certain occasions so I began searching for a workaround besides running it on port 80. I discovered that others have run into the same issue but no real solution. After a bit of digging I discovered that by editing the apache server config files to match the port that was set for the container I could fix the issue.

So in /etc/apache2/sites-enabled/000-default.conf I added :8080 to the first line <VirtualHost :80 *:8080>

then in /etc/apache2/ports.conf just below Listen 80

I added the line Listen 8080

then after running apachectl restart

everything now works as expected

I just wanted to mention this as it seems to be an unresolved minor issue that does have a fix… I assume that there would be an automated way to do this in using the docker file but I am not familiar enough with docker to do that.

visionm45 commented 1 year ago

I would be willing to write up a draft for the docs if desired.

tianon commented 1 year ago

I don't think I'm familiar with the problem you're describing that this fixes -- can you give a little more detail, please?

visionm45 commented 1 year ago

Sorry not sure if this is the right place to discuss this. I just realized this is a repository for docs for many containers. This was meant to be specifically for the official wordpress docker container. I am referring to this same issue

https://wordpress.org/support/topic/wordpress-docker-image/ https://www.reddit.com/r/docker/comments/ulk03s/wordpress_cant_make_loopback_requests_official_wp/ https://forums.docker.com/t/wordpress-docker-image-breaks-rest-api-because-loopback-fails/91886

I just found this though... maybe it could be a better solution. I haven't tested it though.

tianon commented 1 year ago

Ah, specifically the combination of a non-standard expose port and WordPress trying to hit the "external" hostname to loop back to itself, and in development cases that being localhost:xxx and thus not listening. Have I summarized that accurately?

Yeah, maybe a blurb about this is warranted (perhaps with some of those links you've shared). I think extra_hosts is probably the "cleanest" way to handle this, but there's not really a perfect answer here. :see_no_evil:

visionm45 commented 1 year ago

you have. yes its a bit complicated. is this the correct place to discuss this then or would somewhere else be better?