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

How to use procotol HTTP2 to send HTTP request from KrakenD #773

Open
jaimenavarro opened this issue Aug 17, 2023 · 3 comments
Open

How to use procotol HTTP2 to send HTTP request from KrakenD #773

jaimenavarro opened this issue Aug 17, 2023 · 3 comments
Labels

Comments

@jaimenavarro
Copy link

jaimenavarro commented Aug 17, 2023

Environment info:

  • KrakenD version: v2.4.3 (devopsfaith/krakend:watch)
  • System info: docker
Client:
 Version:           24.0.2-rd
 API version:       1.42 (downgraded from 1.43)
 Go version:        go1.20.4
 Git commit:        e63f5fa
 Built:             Fri May 26 16:39:47 2023
 OS/Arch:           darwin/amd64
 Context:           default

Server:
 Engine:
  Version:          23.0.6
  API version:      1.42 (minimum version 1.12)
  Go version:       go1.20.4
  Git commit:       9dbdbd4b6d7681bd18c897a6ba0376073c2a72ff
  Built:            Fri May 12 13:54:36 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.7.0
  GitCommit:        1fbd70374134b891f97ce19c70b6e50c7b9f4e0d
 runc:
  Version:          1.1.7
  GitCommit:        860f061b76bb4fc671f0f9e900f7d80ff93d4eb7
 docker-init:
  Version:          0.19.0
  GitCommit:
  • Hardware specs:
    • MacOS Ventura 13.5
    • 2 GHz Intel Core i5 de 4 núcleos
    • 16 GB 3733 MHz LPDDR4X

Describe what are you trying to do:
Currently, it seems to be that the default behavior for the HTTP client to send requests to the endpoints in the configuration is using protocol HTTP1.

 [curl] -----(HTTP2+SSL)-----> [KrakenD] ------- HTTP1+SSL -----> [Server wich accepts (HTTP2)]

We receive an HTTP code 464 because the ALB in AWS only accepts HTTP2 requests.

curl -v http://localhost:8080/http2-check --http2-prior-knowledge
*   Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080 (#0)
* h2 [:method: GET]
* h2 [:scheme: http]
* h2 [:authority: localhost:8080]
* h2 [:path: /http2-check]
* h2 [user-agent: curl/8.1.2]
* h2 [accept: */*]
* Using Stream ID: 1 (easy handle 0x7ff06200fe00)
> GET /http2-check HTTP/2
> Host: localhost:8080
> User-Agent: curl/8.1.2
> Accept: */*
>
< HTTP/2 464
< date: Thu, 17 Aug 2023 16:10:17 GMT
< server: awselb/2.0
< x-krakend: Version 2.4.3
< x-krakend-completed: false
< content-length: 0
<
* Connection #0 to host localhost left intact

I would like to send requests to the downstream backends or endpoints using HTTP2.

 [curl] -----(HTTP2+SSL)-----> [KrakenD] ------- HTTP2+SSL -----> [Server wich accepts (HTTP2)]

Here, an example of sending an HTTP request using HTTP2 protocol directly to the Server.

curl -v 'https://api.sandbox-1.edge-gateway.cloudns.ph/dummy/v1/'
*   Trying 15.197.213.219:443...
* Connected to api.sandbox-1.edge-gateway.cloudns.ph (15.197.213.219) port 443 (#0)
* ALPN: offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* (304) (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN: server accepted h2
* Server certificate:
*  subject: CN=*.sandbox-1.edge-gateway.cloudns.ph
*  start date: Aug 16 00:00:00 2023 GMT
*  expire date: Sep 13 23:59:59 2024 GMT
*  subjectAltName: host "api.sandbox-1.edge-gateway.cloudns.ph" matched cert's "*.sandbox-1.edge-gateway.cloudns.ph"
*  issuer: C=US; O=Amazon; CN=Amazon RSA 2048 M03
*  SSL certificate verify ok.
* using HTTP/2
* h2 [:method: GET]
* h2 [:scheme: https]
* h2 [:authority: api.sandbox-1.edge-gateway.cloudns.ph]
* h2 [:path: /dummy/v1/]
* h2 [user-agent: curl/8.1.2]
* h2 [accept: */*]
* Using Stream ID: 1 (easy handle 0x7ff16b80c800)
> GET /dummy/v1/ HTTP/2
> Host: api.sandbox-1.edge-gateway.cloudns.ph
> User-Agent: curl/8.1.2
> Accept: */*
>
< HTTP/2 200
< server: awselb/2.0
< date: Thu, 17 Aug 2023 16:21:13 GMT
< content-type: application/json; charset=utf-8
< content-length: 729
< etag: W/"2d9-ba+dyoDq+wqI1q5vpvLtrFTw+Jw"
< x-krakend: Version 2.3.2
< x-krakend-commit: latest
< x-krakend-completed: false
< x-krakend-region: us-east-1
< x-powered-by: Express
<
* Connection #0 to host api.sandbox-1.edge-gateway.cloudns.ph left intact
{"MessageResponse":"Region: us-east-1. HTTP Response code: 200. Delay response: 0 seconds.","SocketRequest":"::ffff:10.89.64.10:54686","HeadersRequest":{"x-forwarded-for":"79.116.196.75, 10.88.65.65","x-forwarded-proto":"http","x-forwarded-port":"80","host":"dummy-svc-us-east-1.core-svcs.sandbox-1.cloud.siriusxm.com","x-amzn-trace-id":"Root=1-64de48f9-6a1b2748019d884b3ef69d42","user-agent":"curl/8.1.2","accept":"*/*","x-b3-sampled":"1","x-b3-spanid":"6ad97a23d1727999","x-b3-traceid":"3faa362d5743a7c72acb8c758e6e847b","x-forwarded-host":"api.sandbox-1.edge-gateway.cloudns.ph","x-forwarded-via":"KrakenD Version 2.3.2","x-sxm-client-ip":"79.116.196.75","accept-encoding":"gzip"},"HeadersResponse":{"x-powered-by":"Express"}}

Your configuration file:

{
      "endpoint":  "/http2-check",
      "method": "GET",
      "output_encoding": "no-op",
      "timeout": "10s",
      "@comment": "Send HTTP request to a server which accepts only HTTP2 requests",
      "backend": [
        {
          "url_pattern": "/dummy/v1/",
          "encoding": "no-op",
          "sd": "static",
          "method": "GET",
          "host": [
            "https://api.sandbox-1.edge-gateway.cloudns.ph/"
          ],
          "extra_config": {
          }
        }
      ],
      "extra_config": {
      }
    } ,
make start
Copy link

This issue is marked as stale because it has been open over 90 days with no activity. Remove the stale label or comment or this will be closed in 15 days.

@github-actions github-actions bot added the stale label Nov 16, 2023
Copy link

github-actions bot commented Dec 1, 2023

This issue was closed because it has been marked as stalled for 15 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 1, 2023
@kpacha kpacha reopened this Jan 11, 2024
@kpacha kpacha removed the stale label Jan 11, 2024
Copy link

This issue is marked as stale because it has been open over 90 days with no activity. Remove the stale label or comment or this will be closed in 15 days.

@github-actions github-actions bot added the stale label Apr 11, 2024
@alombarte alombarte removed the stale label May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants