HTTPS service gives 308 Permanent Redirect

Hello Team,

I am struggling with below issue, here is the scenario -

Configured a HTTPS service (here example - https://google.com). And trying CURL to it and expect html page in response.

$ curl https://apigateway.my-company.net/google-test
<html>
<head><title>308 Permanent Redirect</title></head>
<body bgcolor="white">
<center><h1>308 Permanent Redirect</h1></center>
<hr><center>openresty/1.13.6.2</center>
</body>
</html>
  • Service configuration -

    {
    “host”: “google.com”,
    “created_at”: 1563783093,
    “connect_timeout”: 60000,
    “id”: “e605b471-2a69-4bb6-8b12-e1c66b016faf”,
    “protocol”: “https”,
    “name”: “google-website”,
    “read_timeout”: 60000,
    “port”: 443,
    “path”: “/”,
    “updated_at”: 1563783165,
    “retries”: 5,
    “write_timeout”: 60000,
    “tags”: null
    }

  • Route configuration -

    {
    “id”: “4b79e717-81ea-4741-bb29-a2dfd1f509b3”,
    “tags”: null,
    “paths”: [
    “/google-test”
    ],
    “destinations”: null,
    “protocols”: [
    “https”
    ],
    “created_at”: 1563783141,
    “snis”: null,
    “hosts”: [],
    “name”: “google-test”,
    “preserve_host”: false,
    “regex_priority”: 0,
    “strip_path”: true,
    “sources”: null,
    “updated_at”: 1563784249,
    “https_redirect_status_code”: 308,
    “service”: {
    “id”: “e605b471-2a69-4bb6-8b12-e1c66b016faf”
    },
    “methods”: [
    “GET”
    ]
    }

Any clue what could be wrong?

PS: I have already edited https_redirect_status_code to 308.

I tested on kong version 1.2.1 in docker. It just work.

Create Service

curl 127.0.0.1:8001/services -d 'name=google' -d 'url=https://google.com/'

Create Route

curl 127.0.0.1:8001/services/google/routes -d 'paths[]=/google-test'

Testing

curl 127.0.0.1/google-test
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="https://www.google.com/">here</A>.
</BODY></HTML>

Follow Redirect

curl -L 127.0.0.1/google-test
# HTML Page
1 Like

Is there a Load balancer or another proxy that is terminating the TLS infront of Kong? It seems like you are making a HTTPS request but it is presented as an HTTP request to Kong.

1 Like

Thank you all for help :slight_smile:

It solved by adding annotation in my ingress as -
nginx.ingress.kubernetes.io/backend-protocol: “HTTPS”