I’m having issues configuring Kong API to be secure. I followed all the documentation and deployed the helm chart. The curl -vvv output I’m getting is below.
* Trying <IP Address>:443...
* Connected to <url> (<IP Address>) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
* CApath: none
* (304) (OUT), TLS handshake, Client hello (1):
* (304) (IN), TLS handshake, Server hello (2):
* (304) (IN), TLS handshake, Unknown (8):
* (304) (IN), TLS handshake, Certificate (11):
* (304) (IN), TLS handshake, CERT verify (15):
* (304) (IN), TLS handshake, Finished (20):
* (304) (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / AEAD-CHACHA20-POLY1305-SHA256
* ALPN, server accepted to use h2
* Server certificate:
* subject: CN=*
* start date: Mar 22 13:10:09 2022 GMT
* expire date: Mar 19 18:05:35 2023 GMT
* subjectAltName: host "<host>" matched cert's "*
* issuer: <>
* SSL certificate verify ok.
* Using HTTP2, server supports multiplexing
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x125011000)
> GET / HTTP/2
> Host: <host>
> user-agent: curl/7.79.1
> accept: */*
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
< HTTP/2 400
< content-type: text/html; charset=UTF-8
< content-length: 220
< date: Thu, 11 Aug 2022 01:03:32 GMT
< x-kong-upstream-latency: 0
< x-kong-proxy-latency: 1
< via: kong/2.8.1.3-enterprise-edition
<
<html>
<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<center>The plain HTTP request was sent to HTTPS port</center>
</body>
</html>
* Connection #0 to host <host> left intact
It seems like whatever annotation I input to redirect http I’m still getting the bad request.
Since you didnt provide much details as to what you configured or what curl command you ran, there is a lot of guessing…
From what I understand you do curl ip:443 and you get 400 (client error - error in your request) with error The plain HTTP request was sent to HTTPS port.
By default curl uses http protocol so if you omitted protocol from curl - my guess this is what causing your problem. Next thing you want to do is to add redirect to https from http by adding following annotations: konghq.com/https-redirect-status-code: "301" and konghq.com/protocol: "https"