How to have a header routing logic with nginx ingress-controller? How to have a header routing logic with nginx ingress-controller? kubernetes kubernetes

How to have a header routing logic with nginx ingress-controller?


You got bitten by a YAML-ism:

The indentation of your 2nd if block isn't the same as the indentation of the others, and thus YAML thinks you are starting a new key under annotations:

You have

metadata:  name: api-mutli-back  annotations:    nginx.ingress.kubernetes.io/configuration-snippet: |      set $dataflag 0;      if ( $http_content_type ~ "multipart\/form-data.*" ){      set $dataflag 1;      }     if ( $dataflag = 1 ){     set $service_name "backend-data"     }

but you should have:

metadata:  name: api-mutli-back  annotations:    nginx.ingress.kubernetes.io/configuration-snippet: |      set $dataflag 0;      if ( $http_content_type ~ "multipart\/form-data.*" ){      set $dataflag 1;      }      if ( $dataflag = 1 ){      set $service_name "backend-data"      }