How to Set Up Internal Routing in App Platform

App Platform is a Platform-as-a-Service (PaaS) offering that allows developers to publish code directly to DigitalOcean servers without worrying about the underlying infrastructure.

Service components can send and receive traffic on both the public internet and the app’s internal local area network (LAN). You can also define additional HTTP and internal ports for service components. This can help you set up API gateways, backend job processing, and microservice architecture.

By default, other components in an app can communicate with service components over the app’s LAN using the service’s name as a URL. For example, if your app contains a service named web, other components can reach the web component at http://web.

If the service has other internal ports configured, other components can send traffic to a specific port on that service using the following URL syntax, http://your-service-name:port-number. For example, if the web service has configured port 3000, other components can communicate via that service’s port at http://web:3000.

Job and worker components can only send outbound requests to other service components and the internet but cannot receive requests. You cannot customize ports for these types of components.

Configure Additional Internal Ports

By default, services listen on port 80 for HTTP requests, but you can open additional ports on the service by setting the internal_ports field in the app spec. For example, in the following spec, the internal_ports field is set to ports 8080 and 3000.

  name: web
  internal_ports: [8080, 3000]

Ports defined in internal_ports field can accommodate any TCP-based traffic.

Additionally, as long as one port is specified in the service’s internal_ports field of the spec, you can remove the http_port field and any applicable routes specified in the ingress field to make the service inaccessible from the public internet. You can use this configuration to make a service a backend component in your app’s architecture.

To view, upload, or download app specs using the DigitalOcean Control Panel, click the Settings tab for your app to go to the App Settings page. In the App Spec section, click the Edit link.