Configuring Nginx Ingresses Using Annotations
The nginx-ingress add-on in CCE uses the community chart and image. If the default add-on parameters cannot meet your demands, you can add annotations to define what you need, such as the default backend, timeout, and size of a request body.
This section describes common annotations used for creating an ingress of the Nginx type.
- The key value of an annotation can only be a string. Other types (such as Boolean values or numeric values) must be enclosed in quotation marks (""), for example, "true", "false", and "100".
- Nginx Ingress supports native annotations of the community. For details, see Annotations.
- Ingress Type
- Configuring a URL Rewriting Rule
- Interconnecting with HTTPS Backend Services
- Creating a Consistent Hashing Rule for Load Balancing
- Customized Timeout Interval
- Customizing Body Size
- Documentation
Ingress Type
Parameter |
Type |
Description |
Supported Cluster Version |
---|---|---|---|
kubernetes.io/ingress.class |
String |
This parameter is mandatory when an ingress is created by calling the API. For clusters of v1.23 or later, use the parameter ingressClassName. For details, see Using kubectl to Create an Nginx Ingress. |
Only clusters of v1.21 or earlier |
For details about how to use the preceding annotations, see Using kubectl to Create an Nginx Ingress.
Configuring a URL Rewriting Rule
Parameter |
Type |
Description |
---|---|---|
nginx.ingress.kubernetes.io/rewrite-target |
String |
Target URI where the traffic must be redirected. |
nginx.ingress.kubernetes.io/ssl-redirect |
Bool |
Indicates whether the access is available only through SSL. The default value is true when the ingress contains a certificate. |
nginx.ingress.kubernetes.io/force-ssl-redirect |
Bool |
Indicates whether to forcibly redirect a request to HTTPS even if TLS is not enabled for the ingress. When HTTP is used for access, the request is forcibly redirected (status code 308) to HTTPS. |
For details about the application scenarios, see Configuring URL Rewriting Rules for Nginx Ingresses.
Interconnecting with HTTPS Backend Services
Parameter |
Type |
Description |
---|---|---|
nginx.ingress.kubernetes.io/backend-protocol |
String |
If this parameter is set to HTTPS, HTTPS is used to forward requests to the backend service container. |
For details about the application scenarios, see Interconnecting Nginx Ingresses with HTTPS Backend Services.
Creating a Consistent Hashing Rule for Load Balancing
Parameter |
Type |
Description |
---|---|---|
nginx.ingress.kubernetes.io/upstream-hash-by |
String |
Enable consistent hashing for load balancing for backend servers. The parameter value can be an Nginx parameter, a text value, or any combination. For example:
|
For details about the application scenarios, see Nginx Ingresses Using Consistent Hashing for Load Balancing.
Customized Timeout Interval
Parameter |
Type |
Description |
---|---|---|
nginx.ingress.kubernetes.io/proxy-connect-timeout |
String |
Customized connection timeout interval. You do not need to set the unit when setting the timeout interval. The default unit is second. Example: nginx.ingress.kubernetes.io/proxy-connect-timeout: '120' |
Customizing Body Size
Parameter |
Type |
Description |
---|---|---|
nginx.ingress.kubernetes.io/proxy-body-size |
String |
When the body size in a request exceeds the upper limit, error 413 is returned to the client. You can use this parameter to adjust the upper limit of the body size. Example: nginx.ingress.kubernetes.io/proxy-body-size: 8m |
Documentation
For details about annotation parameters supported by Nginx ingresses, see Annotations.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot