From b97e45bccfbbfbd8b87304f4034ca8d1a6b19d47 Mon Sep 17 00:00:00 2001 From: Nathan LeClaire Date: Tue, 10 Jan 2023 09:43:58 -0800 Subject: [PATCH 1/3] =?UTF-8?q?Create=20Posts=20=E2=80=9Cdialing-on-the-pu?= =?UTF-8?q?blic-internet-with-grpc-go-cloudflare-and-caddy=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...with-grpc-go-cloudflare-and-caddy.markdown | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 content/post/dialing-on-the-public-internet-with-grpc-go-cloudflare-and-caddy.markdown diff --git a/content/post/dialing-on-the-public-internet-with-grpc-go-cloudflare-and-caddy.markdown b/content/post/dialing-on-the-public-internet-with-grpc-go-cloudflare-and-caddy.markdown new file mode 100644 index 0000000..2cdc8d8 --- /dev/null +++ b/content/post/dialing-on-the-public-internet-with-grpc-go-cloudflare-and-caddy.markdown @@ -0,0 +1,63 @@ +--- +title: Dialing on the Public Internet With gRPC-Go, Cloudflare, and Caddy +layout: post +date: 2023-01-10T17:38:28.209Z +categories: + - programming +--- +``` `` +$ amostra work https://grpc.domain.com +FATA[2023-01-10T17:43:00Z] ../worker.go:146 failed to call schedule client allocs: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial tcp: lookup tcp///grpc.100brushes.com: Servname not supported for ai_socktype"``` + +Enable support buried deep in menu in https://support.cloudflare.com/hc/en-us/articles/360050483011-Understanding-Cloudflare-gRPC-support + +Caddy config: + +``` `` +grpc.domain.com { + reverse_proxy h2c://127.0.0.1:42000 +}``` + +``` `` +$ amostra work grpc.100brushes.com:443 +FATA[2023-01-10T17:34:01Z] ../worker.go:138 failed to call schedule client allocs: rpc error: code = Unavailable desc = conne +ction error: desc = "error reading server preface: http2: frame too large"``` + +Needed to get system certs + +`diff + +* ``` + systemCertPool, err := x509.SystemCertPool() + ``` +* ``` + if err != nil { + ``` +* ``` + log.Fatal("can't get system cert pool", err) + ``` +* ``` + } + grpc.UseCompressor(gzip.Name) + ``` +* ``` + conn, err := grpc.Dial(cliCtx.Args().Get(0), grpc.WithTransportCredentials(insecure.NewCredentials())) + ``` +* ``` + conn, err := grpc.Dial(cliCtx.Args().Get(0), grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{ + ``` +* ``` + RootCAs: systemCertPool, + ``` +* ``` + }))) + if err != nil { + logrus.Fatalf("fail to dial: %v", err) + } + ``` + + ` + +``` `` +$ amostra work dns:///dev.100brushes.com +... Connected and ready to work ...``` \ No newline at end of file From 5ef311479e8308a81a05dc52d969ceedda86d2e1 Mon Sep 17 00:00:00 2001 From: Nathan LeClaire Date: Tue, 10 Jan 2023 12:45:40 -0500 Subject: [PATCH 2/3] Update dialing-on-the-public-internet-with-grpc-go-cloudflare-and-caddy.markdown --- ...with-grpc-go-cloudflare-and-caddy.markdown | 48 +++++++------------ 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/content/post/dialing-on-the-public-internet-with-grpc-go-cloudflare-and-caddy.markdown b/content/post/dialing-on-the-public-internet-with-grpc-go-cloudflare-and-caddy.markdown index 2cdc8d8..4b1be44 100644 --- a/content/post/dialing-on-the-public-internet-with-grpc-go-cloudflare-and-caddy.markdown +++ b/content/post/dialing-on-the-public-internet-with-grpc-go-cloudflare-and-caddy.markdown @@ -5,59 +5,45 @@ date: 2023-01-10T17:38:28.209Z categories: - programming --- -``` `` + +``` $ amostra work https://grpc.domain.com -FATA[2023-01-10T17:43:00Z] ../worker.go:146 failed to call schedule client allocs: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial tcp: lookup tcp///grpc.100brushes.com: Servname not supported for ai_socktype"``` +FATA[2023-01-10T17:43:00Z] ../worker.go:146 failed to call schedule client allocs: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial tcp: lookup tcp///grpc.100brushes.com: Servname not supported for ai_socktype" +``` -Enable support buried deep in menu in https://support.cloudflare.com/hc/en-us/articles/360050483011-Understanding-Cloudflare-gRPC-support +Enable support buried deep in menu in https://support.cloudflare.com/hc/en-us/articles/360050483011-Understanding-Cloudflare-gRPC-support -Caddy config: +Caddy config: -``` `` -grpc.domain.com { +``` +grpc.domain.com { reverse_proxy h2c://127.0.0.1:42000 -}``` +} +``` -``` `` +``` $ amostra work grpc.100brushes.com:443 FATA[2023-01-10T17:34:01Z] ../worker.go:138 failed to call schedule client allocs: rpc error: code = Unavailable desc = conne -ction error: desc = "error reading server preface: http2: frame too large"``` - -Needed to get system certs +ction error: desc = "error reading server preface: http2: frame too large" +``` -`diff +Needed to get system certs * ``` systemCertPool, err := x509.SystemCertPool() - ``` -* ``` if err != nil { - ``` -* ``` log.Fatal("can't get system cert pool", err) - ``` -* ``` } - grpc.UseCompressor(gzip.Name) - ``` -* ``` conn, err := grpc.Dial(cliCtx.Args().Get(0), grpc.WithTransportCredentials(insecure.NewCredentials())) - ``` -* ``` conn, err := grpc.Dial(cliCtx.Args().Get(0), grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{ - ``` -* ``` RootCAs: systemCertPool, - ``` -* ``` }))) if err != nil { logrus.Fatalf("fail to dial: %v", err) } ``` - ` - -``` `` +``` $ amostra work dns:///dev.100brushes.com -... Connected and ready to work ...``` \ No newline at end of file +... Connected and ready to work ... +``` From 5d2cb5e2a5c4ae7882bd83b13b1d5171d76beba9 Mon Sep 17 00:00:00 2001 From: Nathan LeClaire Date: Tue, 10 Jan 2023 16:20:51 -0500 Subject: [PATCH 3/3] Update dialing-on-the-public-internet-with-grpc-go-cloudflare-and-caddy.markdown --- ...with-grpc-go-cloudflare-and-caddy.markdown | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/content/post/dialing-on-the-public-internet-with-grpc-go-cloudflare-and-caddy.markdown b/content/post/dialing-on-the-public-internet-with-grpc-go-cloudflare-and-caddy.markdown index 4b1be44..c5dc43e 100644 --- a/content/post/dialing-on-the-public-internet-with-grpc-go-cloudflare-and-caddy.markdown +++ b/content/post/dialing-on-the-public-internet-with-grpc-go-cloudflare-and-caddy.markdown @@ -29,19 +29,18 @@ ction error: desc = "error reading server preface: http2: frame too large" Needed to get system certs -* ``` - systemCertPool, err := x509.SystemCertPool() - if err != nil { - log.Fatal("can't get system cert pool", err) - } - conn, err := grpc.Dial(cliCtx.Args().Get(0), grpc.WithTransportCredentials(insecure.NewCredentials())) - conn, err := grpc.Dial(cliCtx.Args().Get(0), grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{ - RootCAs: systemCertPool, - }))) - if err != nil { - logrus.Fatalf("fail to dial: %v", err) - } - ``` +``` +systemCertPool, err := x509.SystemCertPool() +if err != nil { + log.Fatal("can't get system cert pool", err) +} +conn, err := grpc.Dial(cliCtx.Args().Get(0), grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{ + RootCAs: systemCertPool, +}))) +if err != nil { + logrus.Fatalf("fail to dial: %v", err) +} +``` ``` $ amostra work dns:///dev.100brushes.com