Configure HTTP
The http block in your config.cap.yaml defines how your application's web server is exposed and configured. This includes basic settings like ports and replicas, as well as more advanced options like internal routing and health checks.
Basic Configuration
You can enable or disable the HTTP server for your application, define the port it listens on, and specify the number of replicas.
http:
enable: true # Default: true
port: 8080 # Default: 8080 (your container's listening port)
replicas: 2 # Default: 2 (number of web server instances)
| Property | Type | Description | Default |
|---|---|---|---|
enable |
boolean |
Whether to create HTTP ingress and servers for your application. | true |
port |
integer |
The port your container listens on. | 8080 |
replicas |
integer |
The number of web server instances (pods) for your application. | 2 |
Resource Allocation
You can specify CPU and memory resources for your HTTP servers using the resources property.
http:
resources:
cpu: 500m # 500 millicores (0.5 CPU)
memory: 1Gi # 1 Gigabyte of memory
See the YAML Schema Reference for more details on computeResources syntax.
Internal Routing
The internal option exposes an additional internal Ingress and Service, allowing other applications within the cluster to route traffic to your application without leaving the Kubernetes cluster. This can be useful for microservice architectures.
When enabled, other applications can route traffic towards http://{app slug}-ingress.{namespace}.svc.cluster.local. For example, http://my-app-ingress.my-project-production.svc.cluster.local.
http:
internal: true
| Property | Type | Description | Default |
|---|---|---|---|
internal |
boolean |
When enabled, creates a domain usable for internal communication to the application. | false |
Session Management
If your application uses sessions that need to be shared or persisted, you can configure a session connection. This typically refers to a caching service.
http:
session:
connection: "cache" # Name of a configured service, e.g., 'cache'
| Property | Type | Description |
|---|---|---|
session.connection |
string |
The name of a declared service (e.g., a Dragonfly cache) to use for session management. |
Request Timeout
You can configure the proxy timeout for HTTP requests.
http:
timeout: 60 # Timeout in seconds
| Property | Type | Description | Default |
|---|---|---|---|
timeout |
integer |
The proxy timeout in seconds. | 60 |
Maximum Body Size
Define the maximum allowed body size for incoming HTTP requests.
http:
maxBodySize: 10M # 10 Megabytes
# maxBodySize: 10240 # 10240 Kilobytes (if integer)
| Property | Type | Description | Default |
|---|---|---|---|
maxBodySize |
integer or string |
The maximum body size for HTTP requests. Can be an integer (in KB) or a string with units (e.g., "10MB", "100Kb"). | 2MB |
Health Checks
Health checks are used to determine if your application is running correctly. CAP can perform HTTP health checks on a specified path.
http:
healthCheck:
enable: true
path: "/ping"
| Property | Type | Description | Default |
|---|---|---|---|
healthCheck.enable |
boolean |
Whether to perform an HTTP health check on the deployment. | true |
healthCheck.path |
string |
The URL path to hit for the health check. | /ping |
Note
The specific health check path (healthCheck.path) may vary depending on your application's framework or configuration. Consult your application's documentation for the correct path.