For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
SSL Redirect
Convert Ingress NGINX SSL redirect annotations to an HTTPRoute RequestRedirect filter.
The ssl-redirect annotation tells NGINX to redirect HTTP to HTTPS. In Gateway API, this becomes a RequestRedirect filter on the HTTPRoute.
Before: Ingress with SSL redirect
cat <<'EOF' > ssl-redirect-ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ssl-redirect-demo
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "true"
spec:
ingressClassName: nginx
rules:
- host: secure.example.com
http:
paths:
- backend:
service:
name: web-app
port:
number: 8080
path: /
pathType: Prefix
EOFConvert
ingress2gateway print --providers=ingress-nginx --emitter=kgateway \
--input-file ssl-redirect-ingress.yaml > ssl-redirect-kgateway.yamlAfter: HTTPRoute with redirect filter
cat ssl-redirect-kgateway.yamlThe HTTPRoute includes a RequestRedirect filter that sends a 301 to HTTPS:
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: ssl-redirect-demo-secure-example-com
spec:
hostnames:
- secure.example.com
parentRefs:
- name: nginx
rules:
- matches:
- path:
type: PathPrefix
value: /
filters:
- type: RequestRedirect
requestRedirect:
scheme: https
statusCode: 301Note
NGINX uses status code 308 by default, but Gateway API standardizes on 301.
Apply
kubectl apply -f ssl-redirect-kgateway.yaml
Was this page helpful?