-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
feat: support listen http2 with plaintext #3547
Changes from 11 commits
9d4a82d
1e25f2a
e082cb0
1684eb5
ae60601
760666b
95b413a
91980e9
c2090f9
a183628
6d6cbf7
5be4e93
854df6f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ Here's an example, to proxying gRPC service by specified route: | |
|
||
* attention: the `scheme` of the route's upstream must be `grpc` or `grpcs`. | ||
* attention: APISIX use TLS‑encrypted HTTP/2 to expose gRPC service, so need to [config SSL certificate](https.md) | ||
* attention: APISIX also support to expose gRPC service with plaintext HTTP/2, which do not need to config SSL certificate, usually used to proxy gRPC service in intranet environment | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. which do not need to config SSL certificate => which doesn't rely on ALPN/NPN extensions in TLS/SSL protocol. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this is a little hard to understand for user...? Maybe it's enough to mention in doc that this feature is supported, and show how to configure it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about "which doesn't rely on TLS/SSL"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright, done :-) |
||
* the grpc server example:[grpc_server_example](https://github.com/iresty/grpc_server_example) | ||
|
||
```shell | ||
|
@@ -54,7 +55,7 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13 | |
}' | ||
``` | ||
|
||
#### testing | ||
#### testing HTTP/2 with TLS‑encrypted | ||
|
||
Invoking the route created before: | ||
|
||
|
@@ -67,6 +68,30 @@ $ grpcurl -insecure -import-path /pathtoprotos -proto helloworld.proto -d '{"n | |
|
||
This means that the proxying is working. | ||
|
||
#### testing HTTP/2 with plaintext | ||
|
||
By default, the APISIX only listens to `9443` for TLS‑encrypted HTTP/2. You can support HTTP/2 with plaintext via the `node_listen` section under `apisix` in `conf/config.yaml`: | ||
|
||
```yaml | ||
apisix: | ||
node_listen: | ||
- port: 9080 | ||
enable_http2: false | ||
- port: 9081 | ||
enable_http2: true | ||
``` | ||
|
||
Invoking the route created before: | ||
|
||
```shell | ||
$ grpcurl -plaintext -import-path /pathtoprotos -proto helloworld.proto -d '{"name":"apisix"}' 127.0.0.1:9081 helloworld.Greeter.SayHello | ||
{ | ||
"message": "Hello apisix" | ||
} | ||
``` | ||
|
||
This means that the proxying is working. | ||
|
||
### gRPCS | ||
|
||
If your gRPC service encrypts with TLS by itself (so called `gPRCS`, gPRC + TLS), you need to change the `scheme` to `grpcs`. The example above runs gRPCS service on port 50052, to proxy gRPC request, we need to use the configuration below: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,3 +91,53 @@ apisix: | |
GET /t | ||
--- response_body | ||
admin_key: null | ||
|
||
|
||
|
||
=== TEST 5: support listen multiple ports with array | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to add tests in t/grpc-proxy-test.sh. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
--- yaml_config | ||
apisix: | ||
node_listen: | ||
- 1985 | ||
- 1986 | ||
--- config | ||
location /t { | ||
content_by_lua_block { | ||
local encode_json = require("toolkit.json").encode | ||
local config = require("apisix.core").config.local_conf() | ||
|
||
ngx.say("node_listen: ", encode_json(config.apisix.node_listen)) | ||
} | ||
} | ||
--- request | ||
GET /t | ||
--- response_body | ||
node_listen: [1985,1986] | ||
--- no_error_log | ||
[error] | ||
|
||
|
||
|
||
=== TEST 6: support listen multiple ports with array table | ||
--- yaml_config | ||
apisix: | ||
node_listen: | ||
- port: 1985 | ||
enable_http2: true | ||
- port: 1986 | ||
enable_http2: true | ||
--- config | ||
location /t { | ||
content_by_lua_block { | ||
local encode_json = require("toolkit.json").encode | ||
local config = require("apisix.core").config.local_conf() | ||
|
||
ngx.say("node_listen: ", encode_json(config.apisix.node_listen)) | ||
} | ||
} | ||
--- request | ||
GET /t | ||
--- response_body | ||
node_listen: [{"enable_http2":true,"port":1985},{"enable_http2":true,"port":1986}] | ||
--- no_error_log | ||
[error] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the number type really needed? I think the following way is enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to be backward compatibility unless it is a bugfix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean the element type inside
node_listen
, not thenode_listen
itself.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also be compatible with this format: