Pilothouse-App / Pilothouse

A command line app for managing a LEMP local development environment based on Docker.
http://pilothouse-app.org
GNU General Public License v2.0
98 stars 17 forks source link

Local domain request fails (from a sibling local site) #112

Closed AaronHolbrook closed 6 years ago

AaronHolbrook commented 6 years ago

Attempting to talk to a sibling domain on local install fails with the following message:

cURL error 7: Failed to connect to another-site.dev port 443: Connection refused

I believe this is due to the local host not being able to resolve the domain name of the other site.

Example: while on wordpress.dev, if I make a wp_remote_get call to another-site.dev that exists, it will fail.

philipnewcomer commented 6 years ago

@AaronHolbrook this should already have been fixed in 0.14.2. Can you confirm what version you're using?

AaronHolbrook commented 6 years ago

I'm using 0.14.0.

I'll upgrade and report back.

AaronHolbrook commented 6 years ago

I updated to 0.14.2 and the same error still persists:

It even seems to do the same thing on port 80 for non-ssl:

AaronHolbrook commented 6 years ago

Maybe we can map the hosts file from the host machine?

https://stackoverflow.com/questions/32079364/how-can-you-make-the-docker-container-use-the-host-machines-etc-hosts-file

philipnewcomer commented 6 years ago

Maybe we can map the hosts file from the host machine?

I've had a solution in place for allowing PHP to connect to local sites for quite some time, which except for your case at the moment, works fine. So I don't see a need to replace that with something else just yet. Besides, simply copying the hosts file entries from the host into the PHP container wouldn't work since the domains point to 127.0.0.1, which when inside the PHP container, would just direct PHP to try to connect to port 80 or 443 of its own container, where nothing is listening.

Does the host you're trying to connect to have the same name as the site directory, or if not, is the host listed in the site's config file? Also, have you restarted pilothouse after updating to 0.14.2?

AaronHolbrook commented 6 years ago

Looks like it's a limit on the alias length: https://www.uow.edu.au/~blane/netapp/ontap/nag/networking/concept/c_oc_netw_maintaining_host_file_limits.html

philipnewcomer commented 6 years ago

Turns out Pilothouse was correctly adding the needed hosts file entries to the PHP container's hosts file. However, each domain was added as an alias of a single hosts file entry, and apparently there is a limit of 34 aliases per hosts file entry (line). Thus, any aliases after the 34th were being ignored. In 0.14.3 I've updated Pilothouse to add a new hosts file entry for each domain, rather than adding multiple aliases to a single line.

AaronHolbrook commented 6 years ago

Confirmed this fixed the issue