Question

Load Balancer 400 - The plain HTTP request was sent to HTTPS port

I’m setting up DO Load Balancer to access my service using Nginx Ingress Controller (without helm). From DO control panel, I can see my nodes are accepting traffic somehow the page throws me 400 bad request with error The plain HTTP request was sent to HTTPS port.

Can one please point me out my mistake?

image alt text
image caption

I wonder if this has anything to do with my health checks? The application is exposing an endpoint to update health check 200, but application expose via port 3000 and health check URL is pointing to 80 atm.

Below’s the annontation use for my LB.

annotations:
    service.beta.kubernetes.io/do-loadbalancer-name: random
    service.beta.kubernetes.io/do-loadbalancer-protocol: "http"
    service.beta.kubernetes.io/do-loadbalancer-tls-passthrough: "true"
    service.beta.kubernetes.io/do-loadbalancer-tls-ports: "443"
    service.beta.kubernetes.io/do-loadbalancer-certificate-id: "masked-my-cert-id"
    service.beta.kubernetes.io/do-loadbalancer-disable-lets-encrypt-dns-records: "false"
    service.beta.kubernetes.io/do-loadbalancer-redirect-http-to-https: "true"
    service.beta.kubernetes.io/do-loadbalancer-healthcheck-port: "3000"
    service.beta.kubernetes.io/do-loadbalancer-healthcheck-protocol: "http"
    service.beta.kubernetes.io/do-loadbalancer-healthcheck-path: "/api/healthcheck"
    service.beta.kubernetes.io/do-loadbalancer-healthcheck-check-interval-seconds: "3"
    service.beta.kubernetes.io/do-loadbalancer-healthcheck-response-timeout-seconds: "5"
    service.beta.kubernetes.io/do-loadbalancer-healthcheck-unhealthy-threshold: "3"
    service.beta.kubernetes.io/do-loadbalancer-healthcheck-healthy-threshold: "5"

Screenshot FYR image alt text


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Resolved my issue.

I need to expose port 443 for my Ingress. I did this by setting up the TLS.

Bobby Iliev
Site Moderator
Site Moderator badge
November 21, 2023

Hey @TommyLeong,

Do you by any chance see any additional messages in your logs? You could try checking the logs for your Ingress Controller and application pods. The logs can provide insights into whether they’re receiving and correctly handling the traffic forwarded by the LoadBalancer.

Also, would you mind sharing your complete YAML file here so I could take a further look?

Besides that, the “400 Bad Request - The plain HTTP request was sent to HTTPS port” error is typically due to misconfigured protocol handling. Here are a few things that you could check:

  1. Ensure your Nginx Ingress is set up to handle HTTPS. TLS passthrough requires that SSL termination happens at the pod level, so your Ingress must be configured accordingly.

  2. Adjust the health check to use HTTPS if your service only listens for HTTPS, since the error suggests that an HTTP request is reaching an HTTPS port.

  3. Make sure the service ports and protocols in your Kubernetes configuration match what’s expected by the Load Balancer.

For a detailed guide on setting up HTTPS with Nginx Ingress on DigitalOcean, check out this DigitalOcean tutorial​.

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel