HTTPS
Set up an HTTPS listener on your API gateway to secure access to your apps.
Before you begin
Follow the Get started guide to install Gloo Gateway, set up a gateway resource, and deploy the httpbin sample app.
Make sure that you have the OpenSSL version of openssl, not LibreSSL. The openssl version must be at least 1.1.
- Check your
openssl
version. If you see LibreSSL in the output, continue to the next step. - Install the OpenSSL version (not LibreSSL). For example, you might use Homebrew.
- Review the output of the OpenSSL installation for the path of the binary file. You can choose to export the binary to your path, or call the entire path whenever the following steps use an
openssl
command.- For example,
openssl
might be installed along the following path:/usr/local/opt/openssl@3/bin/
- To run commands, you can append the path so that your terminal uses this installed version of OpenSSL, and not the default LibreSSL.
/usr/local/opt/openssl@3/bin/openssl req -new -newkey rsa:4096 -x509 -sha256 -days 3650...
- For example,
- Check your
Create a TLS certificate
Create a directory to store your TLS credentials in.
Create a self-signed root certificate. The following command creates a root certificate that is valid for a year and can serve any hostname. You use this certificate to sign the server certificate for the gateway later. For other command options, see the OpenSSL docs.
When generating your Envoy certificates, make sure to use encryption algorithms that are supported in Envoy. To learn more about supported algorithms that you can use for your certificates and keys, see the Envoy documentation.Use the root certificate to sign the gateway certificate.
Create a Kubernetes secret to store your server TLS certificate. You create the secret in the same cluster and namespace that the gateway is deployed to. Optionally, you can label the secret to make it easier to refer to later.
Set up an HTTPS listener
Create a gateway resource and configure an HTTPS listener.
Setting Description spec.gatewayClassName
The name of the Kubernetes gateway class that you want to use to configure the gateway. When you set up Gloo Gateway, a default gateway class is set up for you. To view the gateway class configuration, see Gateway classes and types. spec.listeners
Configure the listeners for this gateway. In this example, you configure an HTTPS gateway that listens for incoming traffic on port 443. spec.listeners.tls.mode
The TLS mode that you want to use for incoming requests. In this example, HTTPS requests are terminated at the gateway and the unencrypted request is forwarded to the service in the cluster. spec.listeners.tls.certificateRefs
The Kubernetes secret that holds the TLS certificate and key for the gateway. The gateway uses these credentials to establish the TLS connection with a client, and to decrypt incoming HTTPS requests. Verify that the status of the gateway shows
ACCEPTED
.Create an HTTP route for the httpbin app and add it to the HTTPS gateway that you created.
Verify that the HTTP route is applied successfully.
Get the external address of the gateway and save it in an environment variable. Note that it might take a few seconds for the gateway address to become available.
Send a request to the httpbin app and verify that you see the TLS handshake and you get back a 200 HTTP response code.
Example output:
Cleanup
You can optionally remove the resources that you created as part of this guide.
Remove the HTTP route for the httpbin app, the HTTPS gateway, and the Kubernetes secret that holds the TLS certificate and key.
Remove the
example_certs
directory that stores your TLS credentials.