Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
visionm45 opened this issue Jan 14, 2023 · 5 comments
Open

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

visionm45 opened this issue Jan 14, 2023 · 5 comments

Comments

@visionm45
Copy link

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 visionm45 changed the title Add documentation to fix loopback problem when port is mapped Add documentation for fix for loopback problem when port is mapped Jan 14, 2023
@visionm45
Copy link
Author

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

@tianon
Copy link
Member

tianon commented Jan 17, 2023

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
Copy link
Author

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
Copy link
Member

tianon commented Jan 26, 2023

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. 🙈

@visionm45
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants