Skip to content

VIP Local Development Environment

Networking

The VIP Local Development Environment uses Docker architecture in order to support the widest range of operating systems and environments. One part where this abstraction breaks down is networking, as that is inherently individual.

Domain names are created for local environments with the following pattern:
<siteSlug>.vipdev.lndo.site

For example, when a local environment’s domain http://test.vipdev.lndo.site/ is loaded in a browser, DNS resolution will find an A record for *.lndo.site that maps to a localhost. That request will then hit a traefik proxy container which is part of the VIP Local Development Environment bound to the localhost 80.

The traefik proxy container will use the full domain name to direct traffic to the correct NGINX container in the internal Docker network.

Port binding

There are several containers that together compose the VIP Local Development Environment. Some of these containers bind host ports to be accessible from outside of their internal network.

Proxy

The traefik proxy container serves as a gateway to the local environment, and will try to bind port 80 and 443 to support http and https traffic. If those ports are taken, backup ports will be used instead.

The proxy container is shared between all VIP Local Development Environments running on the host machine. This makes it possible to run multiple dev-env instances simultaneously under different domains.

Other services

Use the info subcommand to see other exposed services that have a port mapped to the host machine on a running VIP Local Development Environment.

vip dev-env info

In the following example output, the exposed services for the local environment with the slug test are PHPMYADMIN, DATABASE, and ENTERPRISE SEARCH.

$ vip dev-env info --slug=test
 NAME               test                                                                                     
 LOCATION           /home/pavel/.local/share/vip/dev-environment/test  
 SERVICES           devtools, nginx, php, database, memcached, phpmyadmin, vip-search, wordpress, mu-plugins, client-code 
 NGINX URLS         http://test.vipdev.lndo.site/      
                    https://test.vipdev.lndo.site/  
 PHPMYADMIN URLS    http://localhost:49170  
 DATABASE           127.0.0.1:49169 
 ENTERPRISE SEARCH  http://127.0.0.1:49168                                
 STATUS             UP               

The ports for these services are selected explicitly to avoid conflicting with any other running environment. For this reason, service ports might change between restarts of an environment.

Troubleshooting

Wildcard DNS resolution is leveraged in order to point to localhost – 127.0.0.1 . In some cases, it is possible for the requested domain to not resolve correctly due to networking configurations on the local machine.

Verify DNS resolution

The dig command can be used to verify domain resolution on the local machine. For example:

$ dig test.vipdev.lndo.site
...
;; ANSWER SECTION:
test.vipdev.lndo.site.	3600	IN	A	127.0.0.1
...

A Docker version of the dig command can be used as an alternative. For example:

$ docker run -it --rm --network=host dig test.vipdev.lndo.site
...
;; ANSWER SECTION:
test.vipdev.lndo.site.	3600	IN	A	127.0.0.1
...

Verify that the domain is reachable

Proxies, tunneling, and security-related tools can also contribute to issues even if the domain resolution is working correctly. The curl command can be used to verify that an environment is reachable. Including the -v switch in the curl command will return all headers in the command output.

In this command example, the X-Powered-By: WordPress VIP header is returned. This indicates that traffic is correctly directed to the local environment.

$ curl -v -o /dev/null test.vipdev.lndo.site
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 127.0.0.1:80...
* TCP_NODELAY set
* Connected to test.vipdev.lndo.site (127.0.0.1) port 80 (#0)
> GET / HTTP/1.1
> Host: test.vipdev.lndo.site
> User-Agent: curl/7.68.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=UTF-8
< Date: Tue, 17 May 2022 13:05:32 GMT
< Host-Header: a9130478a60e5f9135f765b23f26593b
< Link: <https://test.vipdev.lndo.site/wp-json/>; rel="https://api.w.org/"
< Server: nginx/1.21.6
< X-Hacker: If you're reading this, you should visit wpvip.com/careers and apply to join the fun, mention this header.
< X-Powered-By: WordPress VIP <https://wpvip.com>
< X-Robots-Tag: noindex, nofollow
< Transfer-Encoding: chunked
< 
{ [32589 bytes data]
100 80776    0 80776    0     0   355k      0 --:--:-- --:--:-- --:--:--  355k
* Connection #0 to host test.vipdev.lndo.site left intact

A Docker version of the curl command can be used as an alternative. For example:

docker run -it --rm --network=host curl -v -o /dev/null test.vipdev.lndo.site

Last updated: May 20, 2022