Replies: 1 comment
-
If you want to serve the website on both apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: xyz-ingress
annotations:
cert-manager.io/cluster-issuer: "le-prod"
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
spec:
ingressClassName: nginx
tls:
- hosts:
- xyz.com
- www.xyz.com
secretName: mrm-echo-tls
rules:
- host: xyz.com
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: xyz-service
port:
number: 80
- host: www.xyz.com
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: xyz-service
port:
number: 80 But what you probably want is to configure NGINX with a 301 Redirect so that apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: www-xyz-ingress
annotations:
cert-manager.io/cluster-issuer: "le-prod"
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/from-to-www-redirect: "true" # <-- 🌟
spec:
ingressClassName: nginx
tls:
- hosts:
- xyz.com
- www.xyz.com # <-- 🌟
secretName: mrm-echo-tls
rules:
- host: xyz.com
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: xyz-service
port:
number: 80 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'm using cert-manager to create ssl certificates for my app. Below is the yaml i'm using. Though the certificate issued and works well, certificate does not seem to work for
www.xyz.com
it only works forhttps://xyz.com
Any pointers on who to fix this?
Thanks,
Karthik
Beta Was this translation helpful? Give feedback.
All reactions