How to pass extra http headers to Okteto pod?

61 Views Asked by At

I've deployed the Duende IdentityServer to Okteto Cloud: https://id6-jeff-tian.cloud.okteto.net/.

Although the endpoint is https from the outside, the inside pods still think they are behind HTTP protocol. You can check the discovery endpoint to find out: https://id6-jeff-tian.cloud.okteto.net/.well-known/openid-configuration

enter image description here

That causes issues during some redirecting. So how to let the inner pods know that they are hosted in https scheme?

Can we pass some headers to the IdP to tell it the original https schema?

These headers should be forwarded to the inner pods:

X-Forwarded-For: Holds information about the client that initiated the request and subsequent proxies in a chain of proxies. This parameter may contain IP addresses and, optionally, port numbers.

X-Forwarded-Proto: The value of the original scheme, should be https in this case.

X-Forwarded-Host: The original value of the Host header field.

I searched from some aspnet documentations and found this: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/proxy-load-balancer?source=recommendations&view=aspnetcore-6.0, however, I don't know how to configure the headers in Okteto, or in any k8s cluster.

Is there anyone who can shed some light here?

My ingress configurations is as follows (https://github.com/Jeff-Tian/IdentityServer/blob/main/k8s/app/ingress.yaml):

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: id6
  annotations:
    dev.okteto.com/generate-host: id6
spec:
  rules:
    - http:
        paths:
          - backend:
              service:
                name: id6
                port:
                  number: 80
            path: /
            pathType: ImplementationSpecific
1

There are 1 best solutions below

0
On

The headers that you mention are being added to the request when it’s forwarded to your pods.

Could you dump the headers on the receiving end?

Not familiar with Duende, but does it have a setting to specify the “public URL”? That’s typically what I’ve done in the past for similar setups.