easyengine icon indicating copy to clipboard operation
easyengine copied to clipboard

Loopback and WordPress rest api not working due to no connection between the php and the nginx-proxy containers

Open arielferdman opened this issue 2 years ago • 7 comments

System Information

  • [x] ee cli info
  • [x] lsb_release -a
  • [x] docker version
  • [x] docker-compose version

### ee cli info:

OS Linux 5.4.0-77-generic #86-Ubuntu SMP Thu Jun 17 02:35:03 UTC 2021 x86_64 Shell /bin/bash
PHP binary /usr/bin/php7.3
PHP version 7.3.29-1+ubuntu20.04.1+deb.sury.org+1
php.ini used /etc/php/7.3/cli/php.ini
EE root dir phar://ee.phar
EE vendor dir phar://ee.phar/vendor
EE phar path /root
EE packages dir
EE global config /opt/easyengine/config/config.yml
EE project config
EE version 4.3.1

lsb_release -a

No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.3 LTS Release: 20.04 Codename: focal

docker version

Client: Docker Engine - Community Version: 20.10.8 API version: 1.41 Go version: go1.16.6 Git commit: 3967b7d Built: Fri Jul 30 19:54:27 2021 OS/Arch: linux/amd64 Context: default Experimental: true

Server: Docker Engine - Community Engine: Version: 20.10.8 API version: 1.41 (minimum version 1.12) Go version: go1.16.6 Git commit: 75249d8 Built: Fri Jul 30 19:52:33 2021 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.4.9 GitCommit: e25210fe30a0a703442421b0f60afac609f950a3 runc: Version: 1.0.1 GitCommit: v1.0.1-0-g4144b63 docker-init: Version: 0.19.0 GitCommit: de40ad0

docker-compose version

ocker-compose version 1.25.0, build unknown docker-py version: 4.1.0 CPython version: 3.8.10 OpenSSL version: OpenSSL 1.1.1f 31 Mar 2020

Title kinda says it all, I managed to solve this by either adding one of the above mentioned containers to a bridge network containing the other, or by creating another bridge network just for these two containers. Then adding the ip of the nginx-proxy container to the /etc/hosts of the php container with the domain of the website.

Would love to make a pull request that solves this issue.

arielferdman avatar Aug 20 '21 06:08 arielferdman

@mrrobot47 This issue is there for sure. Recently worked on an internal project and found that this issue is present.

Try running cURL from ee shell to the site name itself.

dhsathiya avatar Sep 02 '21 04:09 dhsathiya

@arielferdman can you please check /etc/hosts on your host system (not any containers), if you have any entries starting with 127.0.1.1 then comment it out, undo your existing changes and test the loopback request from WordPress.

mrrobot47 avatar Sep 02 '21 04:09 mrrobot47

@mrrobot47 - I already solved the issue.

arielferdman avatar Sep 02 '21 04:09 arielferdman

@mrrobot47 can I do a pull request with the proposed solution?

arielferdman avatar Sep 02 '21 04:09 arielferdman

can I ask what the solution is?

ssuess avatar Oct 30 '21 07:10 ssuess

@arielferdman can you please check /etc/hosts on your host system (not any containers), if you have any entries starting with 127.0.1.1 then comment it out, undo your existing changes and test the loopback request from WordPress.

I commented out that entry and it worked. Error is resolved. After reading more over at Ubuntu on the purpose of that extra 127/8 entry, I substituted the static IP of the server and the status remains the same. Working.

I don't think this is something that should be addressed by Easyengine as this configuration exists when the VM is created and not when EE is installed or a site is created. I did notice that this problem only surfaced when I started to name my VM's based on the URL of the site that would be created on that VM. For example: VM1 hostname is webserver1 and the /etc/hosts file has the following entries: 127.0.0.1 localhost 127.0.1.1 webserver1 Install EE and create a site called mysite.com. No issues with the looopback.

VM2 hostname is mysite.com and the /etc/hosts file has the following entries: 127.0.0.1 localhost 127.0.1.1 mysite.com Install EE and create a site called mysite.com. Loopback and rest api issues surface.

In the case of VM2, one could either substitute the IP address as mentioned above or just comment out the 127.0.1.1 entry to get the site healty.

freedog96150 avatar May 19 '22 02:05 freedog96150

can I ask what the solution is?

Look at the end of my first comment.

arielferdman avatar Jul 08 '22 08:07 arielferdman