Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kong Router's Protocol Unexpected #8073

Closed
1 task done
alittlecat-x opened this issue Nov 11, 2021 · 6 comments
Closed
1 task done

Kong Router's Protocol Unexpected #8073

alittlecat-x opened this issue Nov 11, 2021 · 6 comments
Labels
core/router pending author feedback Waiting for the issue author to get back to a maintainer with findings, more details, etc... stale task/needs-investigation Requires investigation and reproduction before classifying it as a bug or not.

Comments

@alittlecat-x
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Kong version ($ kong version)

2.4.1

Current Behavior

Router Config

hosts: ["a.b.com"]
paths: ["/"]
protocols: ["http"]
strip_path: false
preserve_host: false
Others is default

Expected Behavior

Only one router's host is a.b.com, and its protocol is http.
But when I ran command curl https://a.b.com/ -k -i, response was not 404 (no router error).

Steps To Reproduce

No response

Anything else?

No response

@javierguerragiraldez
Copy link
Contributor

Hi @alittlecat-x do you get any message in the logs?

@alittlecat-x
Copy link
Author

Hi @javierguerragiraldez
I have a global plugin, my plugin can log request message.

Like this

First I request http://a.b.com/

curl --resolve a.b.com:80:10.26.9.75 -i http://a.b.com/
HTTP/1.1 200 OK
Date: Thu, 25 Nov 2021 08:48:51 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 7
Connection: close

test

Then I got a log

2021/11/25 16:48:51 [error] 11134#0: *2378580022 [lua] log.lua:28: access(): [plugin] [ACCESS] [LOG]{"request":{"req_uri":"/","x_real_ip":"10.26.9.239","status":200,"method":"GET","timestamp":1637830131,"req_start":1637830131702,"remote_addr":"10.26.9.239","req_time":"0.019","upstream_addr":"10.26.28.29:8001","user_agent":"curl/7.29.0","scheme":"http","body_bytes_sent":"7","host":"a.b.com"}}[GOL] while logging request, client: 10.26.9.239, server: kong, request: "GET / HTTP/1.1", upstream: "http://10.26.28.29:8001/", host: "a.b.com"

Then I request https://a.b.com/

curl --resolve a.b.com:443:10.26.9.75 -i -k https://a.b.com/

HTTP/1.1 200 OK
Date: Thu, 25 Nov 2021 08:49:55 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 7
Connection: close

test

I got a log

2021/11/25 16:49:55 [error] 11131#0: *2378601328 [lua] log.lua:28: access(): [plugin] [ACCESS] [LOG]{"request":{"req_uri":"/","x_real_ip":"10.26.9.239","status":200,"method":"GET","timestamp":1637830195,"req_start":1637830195896,"remote_addr":"10.26.9.239","req_time":"0.016","upstream_addr":"10.26.28.29:8001","user_agent":"curl/7.29.0","scheme":"https","body_bytes_sent":"7","host":"a.b.com"}}[GOL] while logging request, client: 10.26.9.239, server: kong, request: "GET / HTTP/1.1", upstream: "http://10.26.28.29:8001/", host: "a.b.com"

Plugin writes logs in error.log. I didn't get any other errors.

Service

{
  "write_timeout": 60000,
  "retries": 5,
  "tags": [],
  "ca_certificates": null,
  "id": "2bc5cbf6-c27f-43c3-bbd5-87f8099569c1",
  "tls_verify": null,
  "port": 80,
  "tls_verify_depth": null,
  "client_certificate": null,
  "created_at": 1637829885,
  "updated_at": 1637829901,
  "connect_timeout": 60000,
  "read_timeout": 60000,
  "path": "/",
  "protocol": "http",
  "name": "a.b.com-test",
  "host": "a.b.com-test",
  "extras": {
    "createdUser": null,
    "updatedUser": null,
    "id": 17,
    "service_id": "2bc5cbf6-c27f-43c3-bbd5-87f8099569c1",
    "kong_node_id": "3",
    "description": null,
    "tags": null,
    "createdAt": "2021-11-25T08:44:46.000Z",
    "updatedAt": "2021-11-25T08:45:01.000Z"
  }
}

Route

{
  "response_buffering": true,
  "snis": null,
  "https_redirect_status_code": 426,
  "preserve_host": false,
  "tags": null,
  "id": "1ec92804-1058-4130-831e-afe8744831b7",
  "protocols": [
    "http"
  ],
  "paths": [
    "/"
  ],
  "methods": null,
  "created_at": 1637829954,
  "updated_at": 1637829954,
  "destinations": null,
  "strip_path": false,
  "service": {
    "write_timeout": 60000,
    "retries": 5,
    "tags": [],
    "ca_certificates": null,
    "id": "2bc5cbf6-c27f-43c3-bbd5-87f8099569c1",
    "tls_verify": null,
    "port": 80,
    "tls_verify_depth": null,
    "client_certificate": null,
    "created_at": 1637829885,
    "updated_at": 1637829901,
    "connect_timeout": 60000,
    "read_timeout": 60000,
    "path": "/",
    "protocol": "http",
    "name": "a.b.com-test",
    "host": "a.b.com-test",
    "extras": {
      "createdUser": null,
      "updatedUser": null,
      "id": 17,
      "service_id": "2bc5cbf6-c27f-43c3-bbd5-87f8099569c1",
      "kong_node_id": "3",
      "description": null,
      "tags": null,
      "createdAt": "2021-11-25T08:44:46.000Z",
      "updatedAt": "2021-11-25T08:45:01.000Z"
    }
  },
  "hosts": [
    "a.b.com"
  ],
  "headers": null,
  "path_handling": "v1",
  "sources": null,
  "regex_priority": 0,
  "name": "a.b.com-test",
  "request_buffering": true
}

Upstream

{
  "hash_on": "none",
  "created_at": 1637830052,
  "host_header": null,
  "name": "a.b.com-test",
  "hash_on_cookie": null,
  "hash_on_cookie_path": "/",
  "tags": null,
  "hash_fallback_header": null,
  "id": "671c37b4-8617-443e-9227-939d010e424a",
  "algorithm": "round-robin",
  "healthchecks": {
    "threshold": 0,
    "active": {
      "https_verify_certificate": true,
      "healthy": {
        "successes": 0,
        "interval": 0,
        "http_statuses": [
          200,
          302
        ]
      },
      "https_sni": null,
      "unhealthy": {
        "tcp_failures": 0,
        "timeouts": 0,
        "http_failures": 0,
        "interval": 0,
        "http_statuses": [
          429,
          404,
          500,
          501,
          502,
          503,
          504,
          505
        ]
      },
      "concurrency": 10,
      "http_path": "/",
      "timeout": 1,
      "type": "http"
    },
    "passive": {
      "type": "http",
      "healthy": {
        "successes": 0,
        "http_statuses": [
          200,
          201,
          202,
          203,
          204,
          205,
          206,
          207,
          208,
          226,
          300,
          301,
          302,
          303,
          304,
          305,
          306,
          307,
          308
        ]
      },
      "unhealthy": {
        "tcp_failures": 0,
        "timeouts": 0,
        "http_failures": 0,
        "http_statuses": [
          429,
          500,
          503
        ]
      }
    }
  },
  "slots": 1000,
  "hash_fallback": "none",
  "client_certificate": null,
  "hash_on_header": null
}

@bungle
Copy link
Member

bungle commented Nov 30, 2021

I am pretty sure the protocol is somewhat different than other fields. E.g. there is also this redirection logic:
https://github.com/Kong/kong/blob/master/kong/db/schema/entities/routes.lua#L41-L44

But the issue seems to be that https route is matched with http route. I have a vague memory that this is not implemented completely. I don't remember a reason for it, so we should revisit this.

@javierguerragiraldez javierguerragiraldez added the task/needs-investigation Requires investigation and reproduction before classifying it as a bug or not. label Dec 1, 2021
@hanshuebner
Copy link
Contributor

Does this issue still exist with Kong Gateway 3.x?

@hanshuebner hanshuebner added the pending author feedback Waiting for the issue author to get back to a maintainer with findings, more details, etc... label Feb 7, 2023
@stale
Copy link

stale bot commented Mar 2, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 2, 2023
@hbagdi
Copy link
Member

hbagdi commented Mar 2, 2023

Closing this due to lack of activity. Please re-open if needed.

@hbagdi hbagdi closed this as completed Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core/router pending author feedback Waiting for the issue author to get back to a maintainer with findings, more details, etc... stale task/needs-investigation Requires investigation and reproduction before classifying it as a bug or not.
Projects
None yet
Development

No branches or pull requests

5 participants