How to redirect target to correct path?

781 views
Skip to first unread message

yjs...@gmail.com

unread,
May 28, 2020, 4:21:49 AM5/28/20
to haproxy-ingress
All,

    I try to use  haproxy as load balance and  haproxy-ingress as ingress controller in k8s. 

my  load balance config:

1.png


my ingress:
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: li
  namespace: li
  annotations:
    # add an annotation indicating the issuer to use.
    cert-manager.io/cluster-issuer: "letsencrypt-staging"
    #haproxy.org/forwarded-for: true
    kubernetes.io/ingress.class: haproxy
    ingress.kubernetes.io/ssl-redirect: "true"
spec:
  rules:
  - host: a.b.c
    http:
      paths:
      - path: /storage
        backend:
          serviceName: li-frontend
          servicePort: 80
  tls:
  - hosts:
    - a.b.c
    secretName: longhorn-ui-tls

li-frontend is a dashboard ui service.

All is ok when I set the path field to blank in my ingress. and page is not normal when  the path field seted to /storage or any non blank value.

I find some link not get correct position, e.g.
requst             correct value
/main.js           /storage/main.js

I found  this in nginx-ingress:
#rewrite ^/main(.*)$ /storage/main$1 redirect;

Does haproxy-ingress has same function?

I try these, but no effect:
 
In addition, I use rewrite in nginx-ingress, but it don't work on websocket.

Sorry for my pool english.

Joao Morais

unread,
May 31, 2020, 8:52:42 AM5/31/20
to haproxy...@googlegroups.com
On Thu, May 28, 2020 at 5:21 AM <yjs...@gmail.com> wrote:
>
> I found this in nginx-ingress:
>>
>> #nginx.ingress.kubernetes.io/configuration-snippet: |
>>
>> #rewrite ^/main(.*)$ /storage/main$1 redirect;
>
> Does haproxy-ingress has same function?

Yep: https://haproxy-ingress.github.io/docs/configuration/keys/#configuration-snippet

> I try these, but no effect:
>>
>> ingress.kubernetes.io/app-root: /storage
>> ingress.kubernetes.io/rewrite-target: /storage

This does also exist:

* https://haproxy-ingress.github.io/docs/configuration/keys/#configuration-keys
(no direct link to app-root atm)
* https://haproxy-ingress.github.io/docs/configuration/keys/#rewrite-target

> backend TransparentBack_https

This doesn't sound to be a haproxy ingress generated file, perhaps you
are using kubernetes ingress from haproxy tech?

~jm
Reply all
Reply to author
Forward
0 new messages