HTTPS Redirect
To help users or old services find your https endpoints, it is a common practice to redirect http traffic to https endpoints. With Gloo Gateway, this is a simple matter of creating an auxiliary http virtual service that routes to your full https virtual service
Here is an example redirect config (which is used to host these docs). Please take note of a few details which enable this behavior:
-
There are two virtual services, an “auxiliary” and a “main” virtual service.
-
The domain listed in the auxiliary VS matches that of the main VS.
-
The auxiliary VS has a single route which matches all traffic and applies a redirectAction with
httpsRedirect: true
specified.
# auxiliary virtual service to redirect http traffic to the full https virtual service
apiVersion: gateway.solo.io/v1
kind: VirtualService
metadata:
name: docsmgmt-http
namespace: docs
spec:
virtualHost:
domains:
- docs.solo.io
routes:
- matchers:
- prefix: /
redirectAction:
hostRedirect: docs.solo.io
httpsRedirect: true
---
# main virtual service
apiVersion: gateway.solo.io/v1
kind: VirtualService
metadata:
name: docsmgmt
namespace: docs
spec:
sslConfig:
secretRef:
name: docs.solo.io
namespace: gloo-system
sniDomains:
- docs.solo.io
virtualHost:
domains:
- 'docs.solo.io'
routes:
- matchers:
# (put the https routes here)