Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Puoi proteggere il gateway di ingresso con HTTPS utilizzando TLS semplice e attivare le connessioni HTTPS a pagine web specifiche. Inoltre, puoi reindirizzare le connessioni HTTP a HTTPS.
HTTPS crea un canale sicuro su una rete non sicura, proteggendo dagli attacchi man-in-the-middle e criptando il traffico tra il client e il server. Per preparare un server web ad accettare connessioni HTTPS, un amministratore deve creare un certificato di chiave pubblica per il server. Affinché un browser web lo accetti senza avviso, questo certificato deve essere firmato da un'autorità di certificazione attendibile.
Modifica il gateway denominato external-gateway nello spazio dei nomi kf utilizzando l'editor Kubernetes integrato:
kubectl edit gateway -n kf external-gateway
Supponendo di avere un certificato e una chiave per il servizio, crea un secret Kubernetes per il gateway di ingresso. Assicurati che il nome del secret non inizi con istio o prometheus. Per questo esempio, il secret si chiama myapp-https-credential.
Meno di servers:
Aggiungi una sezione per la porta 443.
In tls:, imposta credentialName sul nome del secret appena creato.
In hosts:, aggiungi il nome host del servizio che vuoi proteggere con HTTPS. Può essere impostato su un intero dominio utilizzando un carattere jolly (ad es. *.example.com) o limitato a un solo nome host (ad es. myapp.example.com).
In servers: dovrebbe già essere presente una sezione per la porta HTTP 80. Mantieni questa sezione nella definizione del gateway se vuoi che tutto il traffico venga inviato come HTTP.
Per reindirizzare HTTP ad HTTPS, aggiungi il valore httpsRedirect: true in tls nella sezione del server HTTP. Per riferimento futuro, consulta la documentazione di Istio Gateway. Tieni presente che se aggiungi questo parametro nella sezione in cui hosts è impostato su *, tutto il traffico viene reindirizzato a HTTPS. Se vuoi reindirizzare solo da HTTP a HTTPS per una singola app/un singolo dominio, aggiungi una sezione HTTP separata che specifichi il reindirizzamento.
Di seguito è riportato un esempio di un gateway spec che configura HTTPS per myapp.example.com e reindirizza HTTP a HTTPS per quell'host:
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[],[],null,["# Setting up HTTPS Ingress\n\nYou can secure the ingress gateway with HTTPS by using simple TLS, and enable HTTPS connections to specific webpages. In addition, you can redirect HTTP connections to HTTPS.\n\nHTTPS creates a secure channel over an insecure network, protecting against man-in-the-middle attacks and encrypting traffic between the client and server. To prepare a web server to accept HTTPS connections, an administrator must create a public key certificate for the server. This certificate must be signed by a trusted certificate authority for a web browser to accept it without warning.\n| **Note:** These instructions supplement the Istio instructions to [configure a TLS ingress gateway](https://istio.io/latest/docs/tasks/traffic-management/ingress/secure-ingress), and assume that a valid certificate and private key for the server have already been created.\n\nEdit the gateway named external-gateway in the `kf` namespace using the built-in Kubernetes editor: \n\n```\nkubectl edit gateway -n kf external-gateway\n```\n\n1. Assuming you have a certificate and key for your service, create a Kubernetes secret for the ingress gateway. Make sure the secret name does not begin with `istio` or `prometheus`. For this example, the secret is named `myapp-https-credential`.\n2. Under `servers:`\n 1. Add a section for port 443.\n 2. Under `tls:`, set the `credentialName` to the name of the secret you just created.\n 3. Under `hosts:`, add the host name of the service you want to secure with HTTPS. This can be set to an entire domain using a wildcard (e.g. `*.example.com`) or scoped to just one hostname (e.g. `myapp.example.com`).\n3. There should already be a section under `servers:` for port 80 HTTP. Keep this section in the Gateway definition if you would like all traffic to come in as HTTP.\n4. To redirect HTTP to HTTPS, add the value `httpsRedirect: true` under `tls` in the HTTP server section. See the [Istio Gateway documentation](https://istio.io/latest/docs/reference/config/networking/gateway/) for reference. Note that adding this in the section where `hosts` is set to `*` means that **all** traffic is redirected to HTTPS. If you only want to redirect HTTP to HTTPS for a single app/domain, add a separate HTTP section specifying the redirect.\n\nShown below is an example of a Gateway `spec` that sets up HTTPS for `myapp.example.com` and redirects HTTP to HTTPS for that host: \n\n spec:\n selector:\n istio: ingressgateway\n servers:\n - hosts:\n - myapp.example.com\n port:\n name: https\n number: 443\n protocol: HTTPS\n tls:\n credentialName: myapp-https-credential\n mode: SIMPLE\n - hosts:\n - myapp.example.com\n port:\n name: http-my-app\n number: 80\n protocol: HTTP\n tls:\n httpsRedirect: true\n - hosts:\n - '*'\n port:\n name: http\n number: 80\n protocol: HTTP"]]