<p>beginner here. I am currently trying to configure Ingress to do two things - if the fibonacci route exists, redirect to the function and pass the parameter, if the route doesn't exist, redirect to another website and attach the input there.</p>
<p>So, for example, there are two basic scenarios.</p>
<ol>
<li><a href="https://xxx.amazonaws.com/fibonacci/10" rel="nofollow noreferrer">https://xxx.amazonaws.com/fibonacci/10</a> -&gt; calls fibonacci function with parameter 10 (that works)</li>
<li><a href="https://xxx.amazonaws.com/users/jozef" rel="nofollow noreferrer">https://xxx.amazonaws.com/users/jozef</a> -&gt; calls redirect function which redirects to <a href="https://api.github.com/users/jozef" rel="nofollow noreferrer">https://api.github.com/users/jozef</a></li>
</ol>
<p>I think the service doing the redirect is written correctly, it looks like this.</p>
<pre><code>kind: Service
apiVersion: v1
metadata:
  name: api-gateway-redirect-service
spec:
  type: ExternalName
  externalName: api.github.com
  ports:
    - protocol: TCP
      targetPort: 443
      port: 80 # Default port for image
</code></pre>
<p>This is how my Ingress looks like. Experimented with default-backend annotation as well as various placement of the default backend, nothing worked. When I try to curl <a href="https://xxx.amazonaws.com/users/jozef" rel="nofollow noreferrer">https://xxx.amazonaws.com/users/jozef</a>, I keep getting 301 message but the location is unchanged. The final output looks like this</p>
<pre><code>HTTP/1.1 301 Moved Permanently
Server: openresty/1.15.8.2
Date: Wed, 13 Nov 2019 15:52:14 GMT
Content-Length: 0
Connection: keep-alive
Location: https://xxx.amazonaws.com/users/jozef

* Connection #0 to host xxx.amazonaws.com left intact
* Maximum (50) redirects followed
curl: (47) Maximum (50) redirects followed
</code></pre>
<p>Does someone have an idea what am I doing wrong? This is my Ingress. Also, if it helps, we use Kubernetes version 1.14.6. Thanks a million</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-nginx
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: &quot;false&quot;
    nginx.ingress.kubernetes.io/force-ssl-redirect: &quot;false&quot;
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
  - http:
      paths:
        - path: /fibonacci/(.*)
          backend:
            serviceName: fibonacci-k8s-service
            servicePort: 80
        - path: /(.*)
          backend:
            serviceName: api-gateway-redirect-service
            servicePort: 80
</code></pre>

Jozef
<p>The resolution to the problem was the addition of the <code>'Host: hostname'</code> header  in the curl command. </p>

<p>The service that was handling the request needed  <code>Host: hostname</code> header to properly reply to this request. After the <code>hostname</code> header was provided the respond was correct. </p>

<p>Links: </p>

<p><a href="https://curl.haxx.se/docs/" rel="nofollow noreferrer">Curl docs</a></p>

<p><a href="https://kubernetes.io/docs/concepts/services-networking/ingress/" rel="nofollow noreferrer">Ingress docs</a></p>
