For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
HTTPS
Create an HTTPS listener on your agentgateway proxy so that your proxy listens for secured HTTPS traffic.
Before you begin
Deploy the httpbin sample app.
Make sure that you have the OpenSSL version of
openssl, not LibreSSL. Theopensslversion must be at least 1.1.Check the
opensslversion that is installed. If you see LibreSSL in the output, continue to the next step.openssl versionInstall the OpenSSL version (not LibreSSL). For example, you might use Homebrew.
brew install opensslReview 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, openssl might be installed along the following path:
Decide whether to set up a listener inline on the Gateway resource or as a separate ListenerSet resource. For more information, see the Listener overview.
Create a TLS certificate
Create a directory to store your TLS credentials in.
mkdir example_certsCreate 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.
# root cert openssl req -x509 -sha256 \ -nodes -days 365 \ -newkey rsa:2048 \ -subj '/O=any domain/CN=*' \ -keyout example_certs/root.key \ -out example_certs/root.crtCreate an OpenSSL configuration that matches the HTTPS hostname you plan to use. This example assumes that you want to use
example.comas your domain. To use a different one, replace everyexample.comreference with the base domain that you want your listener to serve.cat <<'EOF' > example_certs/gateway.cnf [ req ] default_bits = 2048 prompt = no default_md = sha256 distinguished_name = dn req_extensions = req_ext [ dn ] CN = *.example.com O = any domain [ req_ext ] subjectAltName = @alt_names [ alt_names ] DNS.1 = *.example.com DNS.2 = example.com EOFUse the configuration and root certificate to create and sign the gateway certificate.
openssl req -new -nodes -keyout example_certs/gateway.key -out example_certs/gateway.csr -config example_certs/gateway.cnf openssl x509 -req -sha256 -days 365 \ -CA example_certs/root.crt -CAkey example_certs/root.key -set_serial 0 \ -in example_certs/gateway.csr -out example_certs/gateway.crt \ -extfile example_certs/gateway.cnf -extensions req_extCreate a Kubernetes secret to store your server TLS certificate. You create the secret in the same cluster and namespace that the gateway will be deployed to.
kubectl create secret tls -n agentgateway-system https \ --key example_certs/gateway.key \ --cert example_certs/gateway.crt kubectl label secret https example=httpbin-https --namespace agentgateway-system
Set up an HTTPS listener
Set up an HTTPS listener on your Gateway.
Create a Gateway resource with an HTTPS listener. The following Gateway listener terminates incoming TLS traffic on port 443 by using the TLS certificates that you created earlier.
kubectl apply -f- <<EOF apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: https namespace: agentgateway-system labels: example: httpbin-https spec: gatewayClassName: enterprise-agentgateway listeners: - protocol: HTTPS port: 8443 name: https tls: mode: Terminate certificateRefs: - name: https kind: Secret allowedRoutes: namespaces: from: All EOFReview the following table to understand this configuration.
Setting Description spec.gatewayClassNameThe name of the Kubernetes GatewayClass that you want to use to configure the Gateway. When you set up Solo Enterprise for agentgateway, a default GatewayClass is set up for you. spec.listenersConfigure the listeners for this Gateway. The Gateway can serve HTTPS routes from any namespace. spec.listeners.tls.modeThe 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.certificateRefsThe 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. Create a Gateway that enables the attachment of ListenerSets.
kubectl apply -f- <<EOF apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: https namespace: agentgateway-system labels: example: httpbin-https spec: gatewayClassName: enterprise-agentgateway allowedListeners: namespaces: from: All listeners: - protocol: HTTP port: 80 name: http-mock allowedRoutes: namespaces: from: All EOFReview the following table to understand this configuration.
Setting Description spec.gatewayClassNameThe name of the Kubernetes GatewayClass that you want to use to configure the Gateway. When you set up Solo Enterprise for agentgateway, a default GatewayClass is set up for you. spec.allowedListenersEnable the attachment of ListenerSets to this Gateway. The example allows listeners from any namespace, which is helpful in multitenant environments. You can also limit the allowed listeners. To limit to listeners in the same namespace as the Gateway, set this value to Same. To limit to listeners with a particular label, set this value toSelector.spec.listenersOptionally, you can configure a listener that is specific to the Gateway. Note that due to a Gateway API limitation, you must configure at least one listener on the Gateway resource, even if the listener is not used and is a generic, “mock” listener. This generic listener cannot conflict with the listener that you configure in the ListenerSet, such as using the same port or name. In this example, the generic listener is configured on port 80, which differs from port 443 in the ListenerSet that you create later. Create a ListenerSet that configures an HTTPS listener for the Gateway.
kubectl apply -f- <<EOF apiVersion: gateway.networking.k8s.io/v1 kind: ListenerSet metadata: name: my-https-listenerset namespace: agentgateway-system labels: example: httpbin-https spec: parentRef: name: https namespace: agentgateway-system kind: Gateway group: gateway.networking.k8s.io listeners: - protocol: HTTPS port: 8443 hostname: https.example.com name: https-listener-set tls: mode: Terminate certificateRefs: - name: https kind: Secret allowedRoutes: namespaces: from: All EOFReview the following table to understand this configuration.
Setting Description spec.parentRefThe name of the Gateway to attach the ListenerSet to. spec.listenersConfigure the listeners for this ListenerSet. In this example, you configure an HTTPS gateway that listens for incoming traffic for the https.example.comdomain on port 443. The gateway can serve HTTP routes from any namespace.spec.listeners.tls.modeThe 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.certificateRefsThe 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.
Check the status of the Gateway to make sure that your configuration is accepted. Note that in the output, a
NoConflictsstatus ofFalseindicates that the Gateway is accepted and does not conflict with other Gateway configuration.kubectl get gateway https -n agentgateway-system -o yamlCreate an HTTPRoute resource for the httpbin app that is served by the Gateway or ListenerSet that you created.
kubectl apply -f- <<EOF apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: httpbin-https namespace: httpbin labels: example: httpbin-https spec: hostnames: - https.example.com parentRefs: - name: https namespace: agentgateway-system rules: - backendRefs: - name: httpbin port: 8000 EOFkubectl apply -f- <<EOF apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: httpbin-https namespace: httpbin labels: example: httpbin-https spec: hostnames: - https.example.com parentRefs: - name: my-https-listenerset namespace: agentgateway-system kind: ListenerSet group: gateway.networking.k8s.io rules: - backendRefs: - name: httpbin port: 8000 EOFVerify that the HTTPRoute is applied successfully.
kubectl get httproute/httpbin-https -n httpbin -o yamlExample output: Notice in the
statussection that the parentRef is either the Gateway or the ListenerSet, depending on how you attached the HTTPRoute.... status: ... parentRef: group: gateway.networking.k8s.io kind: Gateway name: https namespace: agentgateway-systemVerify that the listener now has a route attached.
kubectl get gateway -n agentgateway-system https -o yamlExample output:
... listeners: - attachedRoutes: 1kubectl get listenerset -n agentgateway-system my-https-listenerset -o yamlExample output:
... listeners: - attachedRoutes: 1Note that because the HTTPRoute is attached to the ListenerSet, the Gateway does not show the route in its status.
kubectl get gateway -n agentgateway-system https -o yamlExample output:
... listeners: - attachedRoutes: 0If you create another HTTPRoute that attaches to the Gateway and uses the same listener as the ListenerSet, then the route is reported in the status of both the Gateway (attachedRoutes: 1) and the ListenerSet (attachedRoutes: 2).
Get the external address of the gateway and save it in an environment variable.
export INGRESS_GW_ADDRESS=$(kubectl get svc -n agentgateway-system https -o jsonpath="{.status.loadBalancer.ingress[0]['hostname','ip']}") echo $INGRESS_GW_ADDRESSkubectl port-forward svc/https -n agentgateway-system 8443:8443Send a request to the httpbin app and verify that you see the TLS handshake and you get back a 200 HTTP response code.
curl -vik --resolve "https.example.com:8443:${INGRESS_GW_ADDRESS}" https://https.example.com:8443/status/200curl -vik --connect-to https.example.com:8443:localhost:8443 https://https.example.com:8443/status/200Example output:
* Added https.example.com:443:172.18.0.5 to DNS cache * Hostname https.example.com was found in DNS cache * Trying 172.18.0.5:443... * Connected to https.example.com (172.18.0.5) port 443 * ALPN: curl offers h2,http/1.1 * (304) (OUT), TLS handshake, Client hello (1): * (304) (IN), TLS handshake, Server hello (2): * (304) (IN), TLS handshake, Unknown (8): * (304) (IN), TLS handshake, Certificate (11): * (304) (IN), TLS handshake, CERT verify (15): * (304) (IN), TLS handshake, Finished (20): * (304) (OUT), TLS handshake, Finished (20): * SSL connection using TLSv1.3 / AEAD-AES256-GCM-SHA384 / [blank] / UNDEF * ALPN: server accepted h2 * Server certificate: * subject: CN=*.example.com; O=any domain * issuer: O=any domain; CN=* * SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway. * using HTTP/2 * [HTTP/2] [1] OPENED stream for https://https.example.com:443/status/200 * [HTTP/2] [1] [:method: GET] * [HTTP/2] [1] [:scheme: https] * [HTTP/2] [1] [:authority: https.example.com] * [HTTP/2] [1] [:path: /status/200] * [HTTP/2] [1] [user-agent: curl/8.7.1] * [HTTP/2] [1] [accept: */*] > GET /status/200 HTTP/2 > Host: https.example.com > User-Agent: curl/8.7.1 > Accept: */* > * Request completely sent off < HTTP/2 200 HTTP/2 200 ...
Share the HTTPS port with a TLS passthrough listener
An HTTPS listener and a TLS passthrough listener can share a port on one Gateway. The proxy uses each connection’s Server Name Indication (SNI) hostname to select a listener.
- HTTPS: The gateway terminates TLS.
- TLS passthrough: The backend terminates TLS. Use this for services that manage their own certificates or require end-to-end mutual TLS.
Sharing a port avoids a second Gateway and often a second load balancer and IP address. The listeners must claim different hostnames. This example creates a separate https-passthrough Gateway so that the https Gateway from the previous sections stays unchanged. In your own setup, you can add the TLS listener to an existing Gateway instead. For conflict rules, see Listener precedence.
The following steps reuse the root certificate, the https Secret, and the httpbin app from the previous sections.
Create a server certificate for
passthrough.example.com, signed by the existing root certificate. The passthrough backend presents this certificate.openssl req -new -nodes -newkey rsa:2048 \ -keyout example_certs/passthrough.key -out example_certs/passthrough.csr \ -subj "/CN=passthrough.example.com" printf "subjectAltName=DNS:passthrough.example.com\n" > example_certs/passthrough.ext openssl x509 -req -sha256 -days 365 \ -CA example_certs/root.crt -CAkey example_certs/root.key -set_serial 1 \ -in example_certs/passthrough.csr -out example_certs/passthrough.crt \ -extfile example_certs/passthrough.extExample output of the last command:
Certificate request self-signature ok subject=CN=passthrough.example.comStore the certificate in a Secret in the
httpbinnamespace, where the passthrough backend runs.kubectl create secret tls passthrough-server-certs -n httpbin \ --key example_certs/passthrough.key \ --cert example_certs/passthrough.crt kubectl label secret passthrough-server-certs -n httpbin example=httpbin-httpsExample output:
secret/passthrough-server-certs created secret/passthrough-server-certs labeledDeploy an nginx server that terminates TLS with that certificate.
kubectl apply -f- <<EOF apiVersion: v1 kind: ConfigMap metadata: name: passthrough-nginx namespace: httpbin labels: example: httpbin-https data: nginx.conf: | events {} http { server { listen 8443 ssl; server_name passthrough.example.com; ssl_certificate /etc/nginx-server-certs/tls.crt; ssl_certificate_key /etc/nginx-server-certs/tls.key; location / { default_type text/plain; return 200 "hello from the TLS passthrough backend\n"; } } } --- apiVersion: apps/v1 kind: Deployment metadata: name: passthrough-nginx namespace: httpbin labels: example: httpbin-https spec: replicas: 1 selector: matchLabels: app: passthrough-nginx template: metadata: labels: app: passthrough-nginx spec: containers: - name: nginx image: nginx:1.27 ports: - containerPort: 8443 volumeMounts: - name: config mountPath: /etc/nginx/nginx.conf subPath: nginx.conf readOnly: true - name: certs mountPath: /etc/nginx-server-certs readOnly: true volumes: - name: config configMap: name: passthrough-nginx - name: certs secret: secretName: passthrough-server-certs --- apiVersion: v1 kind: Service metadata: name: passthrough-nginx namespace: httpbin labels: example: httpbin-https spec: selector: app: passthrough-nginx ports: - name: https port: 443 targetPort: 8443 EOFExample output:
configmap/passthrough-nginx created deployment.apps/passthrough-nginx created service/passthrough-nginx createdCreate a Gateway with an HTTPS listener and a TLS passthrough listener on port 443.
kubectl apply -f- <<EOF apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: https-passthrough namespace: agentgateway-system labels: example: httpbin-https spec: gatewayClassName: enterprise-agentgateway listeners: - name: https protocol: HTTPS port: 443 hostname: https.example.com tls: mode: Terminate certificateRefs: - name: https kind: Secret allowedRoutes: namespaces: from: All - name: tls-passthrough protocol: TLS port: 443 hostname: passthrough.example.com tls: mode: Passthrough allowedRoutes: namespaces: from: All EOFReview the following table to understand this configuration.
Setting Description spec.listeners[].portBoth listeners use port 443. Only an HTTPSlistener and aTLSlistener can share a port this way. Any other mix of protocols on one port is aProtocolConflict.spec.listeners[].hostnameThe SNI hostname that selects the listener. Each listener on the port must claim a different hostname. spec.listeners[0].tls.modeTerminatefor the HTTPS listener. The gateway decrypts the connection with thehttpsSecret and routes the HTTP request.spec.listeners[1].tls.modePassthroughfor the TLS listener. The gateway forwards the encrypted connection without decrypting it.Create an HTTPRoute for the HTTPS listener and a TLSRoute for the TLS passthrough listener.
kubectl apply -f- <<EOF apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: httpbin-shared-port namespace: httpbin labels: example: httpbin-https spec: parentRefs: - name: https-passthrough namespace: agentgateway-system sectionName: https hostnames: - https.example.com rules: - backendRefs: - name: httpbin port: 8000 --- apiVersion: gateway.networking.k8s.io/v1 kind: TLSRoute metadata: name: passthrough-nginx namespace: httpbin labels: example: httpbin-https spec: parentRefs: - name: https-passthrough namespace: agentgateway-system sectionName: tls-passthrough hostnames: - passthrough.example.com rules: - backendRefs: - name: passthrough-nginx port: 443 EOFExample output:
httproute.gateway.networking.k8s.io/httpbin-shared-port created tlsroute.gateway.networking.k8s.io/passthrough-nginx createdVerify that both listeners are accepted and programmed. Each should have one route attached.
kubectl get gateway https-passthrough -n agentgateway-system \ -o jsonpath='{range .status.listeners[*]}{.name}{": attachedRoutes="}{.attachedRoutes}{"\n"}{range .conditions[*]}{" "}{.type}={.status} ({.reason}){"\n"}{end}{end}'Example output:
https: attachedRoutes=1 Accepted=True (Accepted) Conflicted=False (NoConflicts) Programmed=True (Programmed) ResolvedRefs=True (ResolvedRefs) tls-passthrough: attachedRoutes=1 Accepted=True (Accepted) Conflicted=False (NoConflicts) Programmed=True (Programmed) ResolvedRefs=True (ResolvedRefs)Get the address of the Gateway.
export INGRESS_GW_ADDRESS=$(kubectl get svc -n agentgateway-system https-passthrough -o jsonpath="{.status.loadBalancer.ingress[0]['hostname','ip']}") echo $INGRESS_GW_ADDRESSkubectl port-forward svc/https-passthrough -n agentgateway-system 9443:443Send a request to the HTTPS hostname. The gateway presents its own
*.example.comcertificate and returns the httpbin response.curl -v --cacert example_certs/root.crt --resolve "https.example.com:443:${INGRESS_GW_ADDRESS}" https://https.example.com/status/200curl -v --cacert example_certs/root.crt --connect-to https.example.com:443:localhost:9443 https://https.example.com/status/200Example output:
* ALPN: server accepted h2 * Server certificate: * subject: CN=*.example.com; O=any domain * subjectAltName: host "https.example.com" matched cert's "*.example.com" * issuer: O=any domain; CN=* ... < HTTP/2 200Send a request to the passthrough hostname. The gateway forwards the encrypted connection. The nginx server presents its
passthrough.example.comcertificate and answers the request.curl -v --cacert example_certs/root.crt --resolve "passthrough.example.com:443:${INGRESS_GW_ADDRESS}" https://passthrough.example.com/curl -v --cacert example_certs/root.crt --connect-to passthrough.example.com:443:localhost:9443 https://passthrough.example.com/Example output:
* ALPN: server accepted http/1.1 * Server certificate: * subject: CN=passthrough.example.com * subjectAltName: host "passthrough.example.com" matched cert's "passthrough.example.com" * issuer: O=any domain; CN=* ... < HTTP/1.1 200 OK < Server: nginx/1.27.5 ... hello from the TLS passthrough backend
Cleanup
You can remove the resources that you created in this guide.kubectl delete -A gateways,httproutes,secret -l example=httpbin-https
rm -rf example_certskubectl delete -A gateways,httproutes,listenersets,secret -l example=httpbin-https
rm -rf example_certsIf you shared the HTTPS port with a TLS passthrough listener, also delete the TLSRoute and the nginx server.
kubectl delete -A tlsroutes,deployments,services,configmaps -l example=httpbin-https