Manifest to Redirect Non-www Requests to www When Using ALB with AWS EKS Ingress
2024-05-20 11:20 (22 months ago)
Here is the translation of the provided Japanese blog post content into English:
This is an Ingress manifest that responds to a request without "www" by redirecting to a URL with "www".
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: no-www-ytyng-com-ingress
namespace: ytyng
labels:
app: my-k8s-alb
annotations:
alb.ingress.kubernetes.io/actions.redirect-to-eks: >
{"type": "redirect", "redirectConfig": {"host": "www.ytyng.com", "path": "/", "protocol": "HTTPS", "port":"443", "query": "", "statusCode": "HTTP_301"}}
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS":443}]'
alb.ingress.kubernetes.io/group.name: my-k8s-alb
alb.ingress.kubernetes.io/group.order: "5"
alb.ingress.kubernetes.io/load-balancer-name: my-k8s-alb
spec:
ingressClassName: alb
rules:
- host: ytyng.com
http:
paths:
- pathType: ImplementationSpecific
backend:
service:
name: redirect-to-eks
port:
name: use-annotation
After applying the manifest, check the ALB listener rules and look at the EKS cluster → Resources → Resource Type → Services and Networking → Ingress → the name of this manifest, and check the event logs.
Please rate this article
Currently unrated
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.
We look forward to discussing your development needs.