Skip to content

Instantly share code, notes, and snippets.

@lemonlatte
Created April 6, 2021 09:31
Show Gist options
  • Save lemonlatte/5f9981072887f8363d905c3ab5f04e5c to your computer and use it in GitHub Desktop.
Save lemonlatte/5f9981072887f8363d905c3ab5f04e5c to your computer and use it in GitHub Desktop.
ingress nginx www redirect
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/configuration-snippet: |
if ($host = "www.example.com") {
return 308 https://example.com$request_uri;
}
name: example-www
namespace: example
spec:
rules:
- host: www.example.com
tls:
- secretName: example-www-tls
---
apiVersion: cert-manager.io/v1alpha3
kind: Certificate
metadata:
name: example-www
namespace: example
spec:
commonName: www.example.com
dnsNames:
- www.example.com
issuerRef:
kind: ClusterIssuer
name: letsencrypt
secretName: example-www-tls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment