<p>I'm using Kubernetes that is bundled with Docker-for-Mac. I'm trying to configure an Ingress that routes http requests starting with /v1/ to my backend service and /ui/ requests to my Angular app.</p>

<p>My issues seems to be that the HTTP method of the requests are changed by ingress (NGINX) from a POST to a GET.</p>

<p>I have tried various rewrite rules, but to no avail. I even switched from Docker-for-Mac to Minikube, but the result is the same. </p>

<p>If I use a simple ingress with no paths (just the default backend) then the service is getting the correct HTTP method.
The ingress below works: </p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress
spec:
  backend:
    serviceName: backend
    servicePort: 8080
</code></pre>

<p>But this ingress does not:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"

spec:
  rules:
  - http:
      paths:
      - path: /v1
        backend:
          serviceName: backend
          servicePort: 8080
      - path: /ui
        backend:
          serviceName: webui
          servicePort: 80
</code></pre>

<p>When I debug the "backend" service I see that the HTTP Request is a GET instead of a POST.</p>

<p>I read somewhere that NGINX rewrites issue a 308 (permanent) redirect and the HTTP method is changed from a GET to a POST, but if that is the case how can I configure my ingress to support different paths for different services that require POST calls?</p>

Martin Steiner
<p>I found the solution to my problem. When I add <code>host:</code> to the configuration then the http method is not changed. Here is my current ingress yaml (the rewrite and regex are used to omit sending the /v1 as part of the backend URL)</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  rules:
  - host: localhost
    http:
      paths:
      - path: /v1(/|$)(.*)
        backend:
          serviceName: gateway
          servicePort: 8080
</code></pre>
