Cant make kubectl to communicate to kubeapi through an nginx http proxy `error: specifying a root certificates file with the insecure flag is not allowed`

Asking for help? Comment out what you need so we can get more information to help you!

Cluster information:

Kubernetes version:Server Version: version.Info{Major:“1”, Minor:“20”, GitVersion:“v1.20.13”, GitCommit:“2444b3347a2c45eb965b182fb836e1f51dc61b70”, GitTreeState:“clean”, BuildDate:“2021-11-17T13:00:29Z”, GoVersion:“go1.15.15”, Compiler:“gc”, Platform:“linux/amd64”}

Cloud being used: bare-metal
Installation method:
Host OS: SUSE enterprise
CNI and version:
CRI and version:

Hi,

I have setup a nginx cluster as a proxy to expose kubeapi to a vm. The goal is to be able to run kubectl from that vm and operate the cluster through the nginx proxy.

I have already configured the nginx and the communicate works as shown below:

kubectl – https on port 6442 → nginx proxy (terminates https) – https on port 6442 → kube api

I copied the kubeconfig to the VM and only changed the server address to the one from nginx.

I am currently having the following error:

kubectl version
error: specifying a root certificates file with the insecure flag is not allowed

I would like to understand what is causing this issue and how to get a workaround it

thank you very much