Skip to content

Networking

The VIP Local Development Environment is composed of several Docker containers. Some of these containers bind host ports to be accessible from outside of their internal network.

The traefik proxy container is shared between all local environments running on the host machine. This makes it possible to run multiple dev-env instances simultaneously under different domains. Running multiple local environments simultaneously requires each local environment to have a unique --slug value. The slug value is assigned when the environment is created with the vip dev-env create command.

Unique domain names are created for each local environment with the following pattern:
<slug>.vipdev.lndo.site

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

For example, when a local environment’s domain (e.g. http://example-env.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 the traefik proxy container which is bound to the localhost port 80.

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.

Apply a custom domain

The default pattern for the domain names of a VIP Local Development Environment (e.g. example-env.vipdev.lndo.site) can be overridden with a custom domain (e.g. example-env.example-domain.com).

Note

Custom domains are applied globally and cannot be applied per-local environment. When a custom domain is configured to apply to a local environment, it is applied to every VIP Local Development Environment on a user’s local machine as long as the configuration in the Lando config.yml file exists. This can cause any previously existing local environments to become unresponsive or unreachable.

Custom domains should be configured just prior to creating a local environment. In this example, the custom domain name example-domain.com is configured then a local environment with the slug example-env is created. This enables the local environment to load at example-env.example-domain.com.

When following these instructions, substitute the values example-domain.com and example-env where they appear with the values of the desired custom domain and environment slug.

  1. In the terminal of the user’s local machine, run the following command to create a Lando config.yml file and update it with the value of the custom domain:
mkdir -p ~/.local/share/vip/lando; echo "domain: example-domain.com" > ~/.local/share/vip/lando/config.yml
  1. Create a new environment with the slug value example-env by running the command:
vip dev-env create --slug=example-env

A warning message will appear below the environment’s information output:

WARNING: example-env.example-domain.com resolves to 76.223.84.192 instead of 127.0.0.1. Things may not work as expected.
Please add the following lines to the hosts file on your system:

127.0.0.1 example-env.example-domain.com
  1. Update the hosts file of the local machine in a text editor. Add the values provided in the warning message to enable example-domain.com to resolve at the local IP address 127.0.0.1:
    127.0.0.1 example-env.example-domain.com

If the phpMyAdmin or MailPit services are enabled for the environment, the warning message will include instructions for updates to the hosts file that are necessary for those services to be reachable with the applied custom domain. For example:

127.0.0.1 example-env-pma.example-domain.com
127.0.0.1 example-env-mailpit.example-domain.com

Port binding for services

To identify the exposed services that are running VIP Local Development Environment and have a port mapped to the host machine, run the vip dev-env info command.

In this example output, the exposed services for the local environment with the slug example-env are PHPMYADMIN and ENTERPRISE SEARCH.

$ vip dev-env info --slug=example-env
 SLUG               example-env                                                                                    
 LOCATION           /home/example-user/.local/share/vip/dev-environment/example-env  
 SERVICES           devtools, nginx, php, database, memcached, phpmyadmin, elasticsearch, wordpress, vip-mu-plugins, app-code 
 NGINX URLS         http://example-env.vipdev.lndo.site/      
                    https://example-env.vipdev.lndo.site/  
 PHPMYADMIN URLS    http://localhost:49170  
 ENTERPRISE SEARCH  http://127.0.0.1:49168                                
 STATUS             UP               

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

Connect to the SQL database with a GUI application

phpMyAdmin can be optionally enabled for a local environment by passing --phpmyadmin=y with the vip dev-env create command or the vip dev-env update command.

It is also possible to configure an external GUI application (e.g. TablePlus) connect with the SQL database of a local environment.

The steps below outline the steps to connect a GUI application to a local environment with the slug value example-env:

  1. Run the command vip dev-env info --slug=example-env.
  2. Reference the value for LOCATION in the command output. It will be similar to /home/example-user/.local/share/vip/dev-environment/example-env.
  3. Locate the example-env directory on the local machine by following the path provided by the LOCATION value.
  4. Create a new file in the example-env directory named .lando.local.yml. A .lando.yml should already exist in the example-env directory.
  5. Open .lando.local.yml in a file editor and add the following content:
services:
  database:
    type: compose
    services:
      ports:
        - "13306:3306"
  1. Save the updates made to .lando.local.yml.
  2. In the terminal, restart the local environment by running the command:
vip dev-env start --slug=example-env
  1. Configure the GUI application to connect to the updated and restarted local environment with the values:
    • Username: wordpress
    • Password: wordpress
    • Host: 127.0.0.1 (Do not use localhost.)
    • Port: 13306 (This is the value that was assigned to ports: in .lando.local.yml. In this example 13306 was added, but an arbitrary value can be added as long as it is unique. The value assigned to the port cannot currently be in use on the host for any other services on any other environments.)

Last updated: August 08, 2024

Relevant to

  • WordPress