You need to enable JavaScript to run this app.
Volcengine Kubernetes Engine

Volcengine Kubernetes Engine

Copy page
Download PDF
Customize ALB Ingress forwarding rules
Configuring fixed responses
Copy page
Download PDF
Configuring fixed responses
ALB Ingresses allow you to configure fixed responses. When a request passes through the ALB instance, the ALB instance can directly return a fixed response without the need to forward the request to the back-end service.​
warning​
Before configuring an ALB Ingress, thoroughly read the Considerations for using ALB Ingresses topic. ​
Prerequisites​
  • The alb-ingress-controller add-on has been installed and upgraded to v0.35.0 or later. For details, see Upgrading add-ons.​
Limits​
  • This configuration is supported only when a Standard edition ALB instance is used.​
Procedure​
Creating through the console​
  1. Log in to the VKE console.​
  1. In the left navigation bar, click Cluster.​
  1. On the cluster list page, click the target cluster for which you need to configure an Ingress.​
  1. In the left navigation bar of the cluster management page, click Services and Ingresses > Ingress. On the page that appears, click Create Ingress.​
  • Select Application Load Balancer (ALB) for Ingress type.​
  • Enable Custom forwarding rules and configure the details of the forwarding rules.​
​
Parameter​
Description​
Forwarding conditions​
Configure forwarding conditions, including the domain name, path, and HTTP header.​
  • Forwarding conditions can be configured individually or in combination. When multiple forwarding conditions are configured, the logical relationship between these forwarding conditions is AND. For example, if you configure both a domain name and a path in a forwarding rule, then only requests that match the specified domain name and path will match this forwarding rule.​
  • Multiple values can be configured within the same forwarding condition, and these values have a logical relationship of OR. For example, if you configure multiple values for a domain name condition, requests that match any of the values are a match for the rule.​
Forwarding actions​
Select Back fixed response for the Forwarding actions parameter and configure the returned content.​
  • HTTP response code: The response status code of the fixed response. 2xx, 4xx, and 5xx status codes are supported.​
  • Response body type: The content format of the fixed response. text/plain, text/css, text/html, application/javascript, and application/json are supported.​
  • Response text: The specific content of the fixed response. The content can be 0 to 1024 characters in length.​
​
  1. Click Confirm.​
Creating through kubectl​
An ALB Ingress supports fixed response configurations through annotations. The following content provides an example:​
Warning​
The {{service-name}} field in the annotation must match the name of the back-end service configured in spec.rules. For example, in this case, the correct annotation is ingress.vke.volcengine.com/loadbalancer-actions.service-demo.​
​
apiVersion: networking.k8s.io/v1​
kind: Ingress​
metadata:​
name: alb-ingress # The custom Ingress name.​
namespace: default # Namespace of the Ingress​
annotations:​
ingress.vke.volcengine.com/loadbalancer-actions.{{service-name}}: | # Replace {{service-name}} with the name of the service.​
[​
{​
"type": "FixedResponse",​
"fixedResponseConfig": {​
"content": "response message",​
"contentType": "text/plain",​
"httpCode": "200"​
}​
}​
]​
spec:​
ingressClassName: alb # The name of the ALB instance.​
rules:​
- host: example.com # Domain names for external access​
http:​
paths:​
- pathType: Prefix # Path matching rule, with Prefix (prefix matching) as the default setting.​
path: /path1 # The matching path for the request.​
backend:​
service:​
name: service-demo # The name of the service to be integrated. The name needs to be consistent with the value of {{service-name}} in the loadbalancer-actions.{{service-name}} annotation.​
port: ​
name: use-annotation # The fixed value. When you configure fixed responses, port.name must be use-annotation.​
​
The following table describes fields in the ingress.vke.volcengine.com/loadbalancer-actions.{{service-name}} annotation.​
​
Parameter​
Type​
Description​
Default value​
type​
String​
The action type of the custom forwarding rule. When you configure fixed responses, you need to set the value to FixedResponse.​
No​
fixedResponseConfig.content​
String​
The content of the fixed response. The content can be 0 to 1024 characters in length.​
No​
fixedResponseConfig.contentType​
String​
The content format of the fixed response. text/plain, text/css, text/html, application/javascript, and application/json are supported.​
No​
fixedResponseConfig.httpCode​
String​
The response status code of the fixed response. 2xx, 4xx, and 5xx status codes are supported.​
No​
​
Validating results​
Viewing configuration​
  1. Log in to the ALB console.​
  1. Click Instance in the left navigation bar. In the instance list, find the target ALB instance and click Listener in the Actions column.​
  1. On the listener details page, find the target listener. In the Actions column, click Edit forwarding rules to view the existing forwarding rules of the listener. You can view the newly added fixed response rule.​
  1. For a forwarding rule, click ​alt​ to view rule details. The rule details should be consistent with the configured ones.​
Sending access requests for verification​
tip​
Before verification, make sure that you have deployed back-end applications and services in the cluster. In this example, an Nginx image is used and the service path is /. For deployment steps, see Using ALB Ingresses for service deployment.​
Access the service by using the domain name configured in the ALB Ingress. In this example, 14.***.***.*** is the public IP address of the ALB instance.​
​
curl -I -H "Host: example.com" http://14.***.***.***​
​
The expected result is as follows: When the requested domain is example.com and the original path is /, the system directly returns a fixed response without forwarding the request to the back-end server.​
​
HTTP/1.1 200 OK​
Server: volcalb​
Date: Wed, 03 Dec 2025 08:14:30 GMT​
Content-Type: text/plain; charset=utf-8​
Content-Length: 18​
Connection: keep-alive​
Vary: Accept-Encoding​
​
this is a doc demo​
​
​
Last updated: 2026.07.07 11:15:44