Skip to main content
Version: Weekly Build

Landscape Networking

The services inside one Landscape can reach each other without restrictions, while the Landscape as a whole is isolated from the outside. Traffic from the internet or from other landscapes only enters through a single entry point that the user defines.

This page describes the three parts of that model:

  1. How services inside a Landscape talk to each other.
  2. How traffic from outside enters the Landscape.
  3. How the Workspace Router distributes incoming traffic across several services and external targets.

Communication between services within a landscape​

Every service in a Landscape is reachable from every other service in the same Landscape. No additional configuration is needed.

  • Reactive Services are addressed under a fixed hostname:

    ws-server-<workspace-id>-<reactive-service-name>.workspaces

    Requests go to the ports you configured for that service. For example, a backend service named api in Workspace 12345 that listens on port 8080 is reachable at:

    http://ws-server-12345-api.workspaces:8080
    Ports must be configured

    A service is only reachable on the ports that are declared in its configuration. See Configure ports.

  • Virtual Machines are addressed under a fixed hostname:

    ws-vm-<workspace-id>-<virtual-machine-name>.workspaces
  • Managed Services have dedicated hostnames, based on the Managed Service Provider. Refer to the Managed Service Provider Reference for provider-specific connection details.

Internal only

Hostnames for Reactives and Virtual Machines resolve inside the Landscape only. They cannot be reached from a browser, from another Landscape, or from the public internet. Managed services have different isolation levels, based on the provider.

Ingress traffic​

Every Workspace is exposed under its dev domain. On top of that, you can attach the Workspace to a path on a custom domain. See Connecting Custom Domain for the setup.

All traffic that arrives over the dev domain or a custom domain is routed to one single endpoint inside the Landscape. That endpoint is called the landscapeGateway. In the Landscape configuration you select which service and which port act as the Landscape gateway.

Landscape without a Workspace Router. Traffic from the custom domain and the dev domain goes directly to the frontend service, which is the Landscape gateway. The frontend reaches the backend service over private networking.

Corresponding accessible text description

  1. Open the Landscape Config Editor in your Workspace.
  2. Click the Traffic Routed to badge to open the config.
  3. Select the desired service as the Landscape gateway and choose the port that serves HTTP traffic.

Selecting a reactive service to use as the landscape gateway service. Selecting a reactive service to use as the landscape gateway service.

One gateway per Landscape

A Landscape has at most one Landscape gateway. The port you declare as httpPort must also be declared in the service's ports.

A single service Landscape needs nothing else. The service is the gateway and receives all incoming requests.

Workspace Router​

If you want to make several services reachable from outside under different HTTP paths, add a Codesphere Workspace Router to the Landscape and use it as the Landscape gateway. This is the recommended setup for multi-service Landscapes.

The Workspace Router runs as an extra service in the Landscape. You can scale it like a Reactive or a Managed Container, by choosing a plan and a replica count. You do not configure its image or its startup commands. Codesphere builds and runs the router for you, based on the paths you define.

Landscape with a Workspace Router as the Landscape gateway. The router forwards requests on / to the frontend service, on /api to the backend service, and on /dashboard to a custom target outside the Landscape.

Corresponding accessible text description

Service Networking​

Service networking maps a path to a service and port inside the Landscape.

  1. Add a Codesphere Router service to the Landscape:
  • Option 1: via the Add New Service Modal Adding a Codesphere Router runtime to the landscape via the Add New Service Modal. Adding a Codesphere Router runtime to the landscape via the Add New Service Modal.

  • Option 2: via the Landscape Networking Flyout Adding a Codesphere Router runtime to the landscape via the Landscape Networking Flyout. Adding a Codesphere Router runtime to the landscape via the Landscape Networking Flyout.

  1. Under Service Networking, add a new route.
  2. Enter the Path prefix, for example /api.
  3. Select the target Service and Port. Adding service networking via the Codesphere Router. Adding service networking via the Codesphere Router.

Custom target routing​

Custom target routing maps a path to an arbitrary URL. Use it to forward traffic to endpoints that are not services of the Landscape, for example:

  1. Add a Codesphere Router service to the Landscape, or open the existing Router's settings. (See section 3.1)
  2. Under Custom Targets, add a new route.
  3. Enter the Path prefix.
  4. Enter the target URL. Adding a custom target via the Codesphere Router. Adding a custom target via the Codesphere Router.

Strip path​

Every path mapping supports the stripPath flag. If it is set, the matched path prefix is removed from the request before it is forwarded to the target.

stripPathIncoming requestForwarded to target
false/api/users/api/users
true/api/users/users

Set stripPath: true if your application serves its routes from the root. Leave it at false if your application expects the full path. See Path-Based Routing for how to prepare an application for a subpath.

Templates​

You can use templates in the router configuration. They are resolved at runtime, so the same configuration works across Workspaces.

TemplateDescription
${{ workspace.id }}Resolves to the Workspace ID
${{ team.id }}Resolves to the Team ID
Trade-off of a custom gateway

You can designate any of your own services as the Landscape gateway instead of the Workspace Router. In that case you handle the routing yourself, and path mappings are not available. Also, Codesphere's built-in Request Browser requires a Workspace Router to be able to automatically collect traces.