Dilshan Jayasooriya
Dilshan Jayasooriya

Reputation: 1

Please use HTTPS protocol error on Kong API Gateway

FROM kong:latest

ENV KONG_DATABASE=postgres
ENV KONG_PG_HOST=autorack.proxy.rlwy.net
ENV KONG_PG_PORT=59190  
ENV KONG_PG_USER=user
ENV KONG_PG_PASSWORD=pssword
ENV KONG_PG_DATABASE=railway
ENV KONG_PROXY_ACCESS_LOG=/dev/stdout
ENV KONG_ADMIN_ACCESS_LOG=/dev/stdout
ENV KONG_PROXY_ERROR_LOG=/dev/stderr
ENV KONG_ADMIN_ERROR_LOG=/dev/stder


ENTRYPOINT ["/bin/sh", "-c", "set -e; kong migrations bootstrap; kong start && tail -f /dev/null"]


EXPOSE 8000 8443 8001 8444 8002 8445 8003 8004

using this docker file i have deployed Kong API Gateway on railway.app. And also i have deployed a test backend project. Then i have created Service and Route on Kong as below configurations.

service json

{
  "tags": null,
  "ca_certificates": null,
  "name": "yo_direct_service",
  "connect_timeout": 60000,
  "read_timeout": 60000,
  "host": "kong-bc-one.sample.app",
  "protocol": "https",
  "write_timeout": 60000,
  "enabled": true,
  "retries": 5,
  "tls_verify": null,
  "tls_verify_depth": null,
  "client_certificate": {
    "id": "3f7b5ea8-b84f-4bfb-9ed8-10651019b164"
  },
  "id": "9c2a9507-83fa-487a-9559-4eb23b58dfc9",
  "port": 443,
  "path": "/yo"
}

route json

{
  "tags": [],
  "methods": null,
  "name": "yo_direct_route",
  "request_buffering": true,
  "response_buffering": true,
  "strip_path": true,
  "protocols": [
    "http",
    "https"
  ],
  "path_handling": "v0",
  "regex_priority": 0,
  "headers": null,
  "hosts": null,
  "paths": [
    "/yo"
  ],
  "service": {
    "id": "9c2a9507-83fa-487a-9559-4eb23b58dfc9"
  },
  "id": "c4281174-c1a5-4420-993e-3c695f85a3f2",
  "preserve_host": false,
  "sources": null,
  "https_redirect_status_code": 426,
  "destinations": null,
  "snis": null
}

Then i have try https://kong-dev.sample.app/yo api and got correct response. Then i have change the route configuration to

{
  "tags": [],
  "methods": null,
  "name": "yo_direct_route",
  "request_buffering": true,
  "response_buffering": true,
  "strip_path": true,
  "protocols": [
    "https"
  ],
  "path_handling": "v0",
  "regex_priority": 0,
  "headers": null,
  "hosts": null,
  "paths": [
    "/yo"
  ],
  "service": {
    "id": "9c2a9507-83fa-487a-9559-4eb23b58dfc9"
  },
  "id": "c4281174-c1a5-4420-993e-3c695f85a3f2",
  "preserve_host": false,
  "sources": null,
  "https_redirect_status_code": 426,
  "destinations": null,
  "snis": null
}

Then i have try https://kong-dev.sample.app/yo API and got below error.

{ "message": "Please use HTTPS protocol", "request_id": "f5a1af432973d870f3a5436c040ce52d" }

First i have tried with changing the docker file and nothing worked. And then i have created certificates using

sudo certbot certonly --manual --preferred-challenges=dns -d domain

and uploaded them into certificates on Kong Gateway and add to service. But still error not fixed.

Upvotes: 0

Views: 112

Answers (0)

Related Questions