Missing Custom Headers Using NGINX Ingress Controller on GCP

5/22/2018

I am creating an application based on java 8 and Springboot using docker and kubernetes on Google Cloud Platform. The application is a RESTFull api which has a Http Header named as SIGNATURE. My point is that thru ingress controller the SIGNATURE header isn't being passed.

Scenario

  • Restfull APIs developed in Java and SpringBoot 1.5.8.
  • Postman calling the Rest API sending the SIGNATURE header.
  • API running in a docker image at GCP executed by K8S.
  • NGINX Ingress Controller is being used.
  • Custom http headers are required to send parameters for this api.

Problem

Throw "Missing request header SIGNATURE" exception while executing the api.

Question

How can I passing custom headers from client to the backend using NGINX Ingress Controller?

Artifacts

  • Springboot Controller Code Snippet

public ResponseEntity<TransactionDTO> get( @RequestHeader("SIGNATURE") String apiSignature, @RequestHeader("application/json") String contentType, @PathVariable Long id)

  • Ingress Controller YAML
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: api-ingress
  annotations:
    kubernetes.io/ingress.class: nginx   
    ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
  rules:
  - host: api.domain.com.br
    http:
      paths:
      - path: /manager
        backend:
          serviceName: api-svc
          servicePort: 8086

Thanks in advance...

-- Alexandre Barbosa de Sousa
google-kubernetes-engine
kubernetes-ingress
spring-boot

0 Answers