TLS with OAuth2.0 in K8s application
I am trying to configure my K8s app with TLS. I have 2 containers in that pod, one is OAuth2.0 proxy container and the other container has my backend code.
I am using OAuth2.0 for doing that. So basically, in the OAuth2.0 proxy pod, I provide tls-cert-file and tls-key-file. As I am using OAuth2.0 for authorisation, I figured I can use the same pod to enable HTTPS. However, after OAuth provider redirects to my application, I get 502 bad gateway.
This is the error I obtain in the OAuth container:
Error proxying to upstream server: tls: first record does not look like a TLS handshake
Now I am wondering is this I have configured TLS only on OAuth container and not the backend container?
Or is this something else and configuring TLS on OAuth container is enough?
Solution 1:
After some more tinkering I figured out what was wrong. The error I mentioned above basically means that we're trying to send HTTPS request to a server that typically takes HTTP request.
In my OAuth proxy conf, I had changed upstream
to https
whereas it should be HTTP
.
I was able to establish an end to end encrypted connection after making this change.