"400 bad request-The plain http request was sent to https port" nginx

+1 vote

I've created an ingress rule for my cluster but when I go to the port and try to open it, I get the following error:

Oct 24, 2018 in Kubernetes by Hannah
• 15,340 points
1,518 views

3 answers to this question.

0 votes

You encounter this error because every time a client tries to access your site via HTTP, the request is redirected to HTTPS. It’s because the nginx expects SSL to be used in the transaction yet the original request was plain HTTP, it complains with the error.

In you nginx config file comment the the following line

#ssl on
answered Oct 24, 2018 by Kalgi
• 41,590 points
0 votes

You usually get this error when you try to configure you Nginx to handle both HTTP and HTTPS requests. 

To fix this error, comment out the line below in your configuration or set it to off.

#ssl on 
OR
ssl off

Save and close the file. Then restart the nginx service.

# systemctl restart nginx
OR
$ sudo systemctl restart nginx
answered Apr 30 by Kavya
0 votes

If you check your config file, it says "listen to port 80"(HTTP) and "SSL on". When you point your browser to http://localhost, it tries to connect via HTTP but since you have mentioned SSL it expects to use SSL. 

What you can do is have two separate servers, something like this:

server {
  listen 80;

  // other directives...
}

server {
  listen 443;

  ssl on;
  // SSL directives...

  // other directives...
}
answered Apr 30 by Vaidya

Related Questions In Kubernetes

+1 vote
0 answers

The connection to the server localhost:8080 was refused

$ kubectl get svc The connection to the ...READ MORE

Aug 8 in Kubernetes by Lakshminarayanan
504 views
0 votes
1 answer
0 votes
1 answer

css download not adding /grafana to the URL.

You need to change root_url grafana's server setting to /grafana/: root_url ...READ MORE

answered Sep 12, 2018 in Kubernetes by Kalgi
• 41,590 points
76 views
0 votes
1 answer
0 votes
1 answer

permissions related to AWS ECR

if you add allowContainerRegistry: true, kops will add those permissions ...READ MORE

answered Oct 9, 2018 in Kubernetes by Kalgi
• 41,590 points
69 views
0 votes
1 answer
0 votes
2 answers

Not able to expose port 80 on the host, kubernetes ingress

I was facing the same error. The nginix ...READ MORE

answered Sep 11, 2018 in Kubernetes by Kalgi
• 41,590 points
79 views