application-gateway-kubernetes-ingress
application-gateway-kubernetes-ingress copied to clipboard
Redirect ingress pathbased route to external site
Is your feature request related to a problem? Please describe.
Is it possible to create a redirection rule to an external website?
For example you have an ingress controller with host: test.domain.com and a path based rule /kibana
i'd love to redirect this to the cloud environment of elastic search, which has some weird url like https://51584e5daa8d66s.eu-central-1.aws.cloud.es.io:9243
Describe the solution you'd like
The nginx ingress uses an annotation like the following: nginx.ingress.kubernetes.io/permanent-redirect: https://51584e5daa8d66s.eu-central-1.aws.cloud.es.io:9243
to make this happen.
I can setup such a rule within the portal itself but it does get overwritten bij AGIC every once in a while.. so that's not doable
@Baklap4 even though App Gateway supports redirect to an external URL - we don't have an annotation for the ingress controller to do that. That'd be a great feature to add. I'm going to tag the issue, but not sure how long it'd take us to get to this. Would you be able to take a stab at adding the annotation to this repo?
@bakla4 How exactly nginx permanent-redirect works if multiple hostnames/paths are configured? For example, if we have an ingress
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
annotations:
kubernetes.io/ingress.class: azure/application-gateway
spec:
rules:
- host: www.siteA.com
http:
paths:
- path: /path1
backend:
serviceName: backend-a-1
servicePort: 80
- path: /path2
backend:
serviceName: backend-a-2
servicePort: 80
- host: www.siteB.com
http:
paths:
- path: /pathb1
backend:
serviceName: backend-b-1
servicePort: 80
- path: /pathb2
backend:
serviceName: backend-b-2
servicePort: 80
I don't see how can we set the redirection www.siteB.com/pathb1 to https://google.com with annotation described in https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#permanent-redirect
nginx.ingress.kubernetes.io/permanent-redirect: https://www.google.com
Unless the annotation will set the redirect to external site to all paths in the ingress file. Then we have www.siteB.com/pathb1 path in a separate ingress.yaml file and achieve desired behavior?
Hmm given the above spec it's indeed impossible to do such a thing.
I see nginx also has a rewrite option:
nginx.ingress.kubernetes.io/configuration-snippet: |
if ($host = 'www.siteB.com' ) {
rewrite ^ https://google.com$request_uri permanent;
}
Which basicly rewrites www.siteB.com
to google.com
The other solution would indeed to have multiple ingress.yaml files and achieve the desired behavior.
Hmm given the above spec it's indeed impossible to do such a thing. I see nginx also has a rewrite option:
Which is also not supported at the moment as @delqn said https://github.com/Azure/application-gateway-kubernetes-ingress/issues/513
The other solution would indeed to have multiple ingress.yaml files and achieve the desired behavior.
Yes, but even so, permanent-redirect annotation needs to be implemented in AGIC.
@delqn What do you suggest we do here? I will be happy to contribute but I need some guidance. First of all, can we implement configuration-snippet
annotations or we are blocked by Azure AGW limitations?
Hi,
I would like to redirect to an external site from http://domain.com/yolo
--> http://sauron.com/yolo
without changing the domain (domain.com/yolo
) because of CORS.
On a server/VM with Nginx, I would add the following location into the server block:
server {
...
location /yolo {
proxy_pass http://sauron/yolo;
}
...
}
On Kubernetes with Ingress, I tried to add this config:
annotations:
nginx.ingress.kubernetes.io/configuration-snippet: |
location /yolo {
proxy_pass http://sauron/yolo;
}
But Sadly, it's not working (I have error code 503).
Someone has any idea? 🙏
Has someone got this working? We have some similar thing to implement. What we need to do is change the domain of our current site and we want to the old domain to redirect to the new domain.
Hi @angeloudy ,
I found a good Kubernetes way to do your request. You have to use an "ExternalName" service type. No need to use annotations with Ingress.
https://kubernetes.io/fr/docs/concepts/services-networking/service/#externalname
@delqn Hi, any updates?
Hello @delqn Did you have any news about this ?
Tracked here #1567
Why would you close this issue and open a new one and mentioning it might be a duplicate @akshaysngupta ? The later issue contains far less detail then this issue and doesn't have any of the followers tracking the item