0

I am trying to play with multiple rules on one of my ingress statements:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    ingress.kubernetes.io/balance-algorithm: roundrobin
    ingress.kubernetes.io/maxconn-server: "10"
    #ingress.kubernetes.io/secure-backends: "true"
    ingress.kubernetes.io/secure-verify-ca-secret: "tls-secret-portal"
    ingress.kubernetes.io/ssl-redirect: "true"
  name: ingress-test
  namespace: testing
spec:
  tls:
  - hosts:
    - my.domain.name
    secretName: tls-secret-portal
  rules:
   - host: my.domain.name
     http:
       paths:
         - path: /
           backend:
             serviceName: nginx-service
             servicePort: 8080
         - path: /link
           backend:
             serviceName: apache-service
             servicePort: 8080

Only the nginx-service at / will work. If i swap the paths then only the apache-service will work. If I give them both a path (/link1 and /link2), neither work and I get a 404 not found, the error on the one that does not work is always 404 not found. The certificate works fine and it is not a certificate issue.

Sean

  • do you have a `/link` path in the `apache-service`? the uri is copied verbatim to the backend unless you use a rewrite, doc [here](https://haproxy-ingress.github.io/docs/configuration/keys/#rewrite-target). – Joao Morais Jun 25 '20 at 18:01
  • no there is not, i tried a rewrite rule, ingress.kubernetes.io/rewrite-target: /, however the app is hard coded to my.domain.name/ , so the page with /link comes up with rewrite rule, however any link will fail as it strips the /link. Is there a variable for the target in the rewrite rule for the path? Or a full on reverse proxy? – Sean Iffland Jun 26 '20 at 02:18
  • You wrote: "the app is hard coded to my.domain.name/, so the page with /link comes up with rewrite rule, however any link will fail as it strips the /link." - I am not sure I understand what you mean by that. Can you be more specific? – Matt Jun 26 '20 at 09:35
  • If i go to my.domain.name/link the page displays, but if i click a link on the application hosted there to say /admin instead of going to my.domain.name/link/admin it will simply go to my.domain.name/admin. I know how to solve this using an external reverse proxy, just trying to learn haproxy-ingress (this is just me learning haproxy-ingress not a real production thing). – Sean Iffland Jun 26 '20 at 12:42
  • Rewriting your application is the cleanest way of doing it so I'd suggest you doing that. You can't just rewrite the response content from server and change urls/paths in flight. Well you could in theory but this is not a good idea. If you have come up with any other solutions, please share it, I woulds be happy to see it and hopefully learn sth. @SeanIffland – Matt Jul 06 '20 at 06:49

1 Answers1

0

Rewriting your application is the cleanest way of doing it so I'd suggest you doing that.

You can't just rewrite the response content from server and change urls/paths in flight. It's easier said than done. You could try in theory but generally this is not a good idea.

Matt
  • 7,419
  • 1
  • 11
  • 22