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

feat: support listen http2 with plaintext #3547

Merged
merged 13 commits into from
Feb 19, 2021

Conversation

sysulq
Copy link
Contributor

@sysulq sysulq commented Feb 7, 2021

What this PR does / why we need it:

Details can be found in #3496.

Pre-submission checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first

@sysulq sysulq changed the title feat: support grpc proxy with insecure mode feat: support listen http2 with plaintext Feb 7, 2021
yaml_conf.apisix.node_listen = node_listen
elseif type(yaml_conf.apisix.node_listen) == "table" then
if type(yaml_conf.apisix.node_listen[1]) == "number" then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot capture your mean for this if.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should check every item, what if the user mixes the integer and the table?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only support port with number parameter?




=== TEST 5: support listen multiple ports with array
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add tests in t/grpc-proxy-test.sh.
And need to update the doc/grpc-proxy.md

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

conf/config.yaml Outdated
@@ -31,6 +31,12 @@
#
# If the configured environment variable can't be found, an error will be thrown.
apisix:
node_listen:
- port: 9080 # APISIX listening port
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should provide the configuration separately in:

res=`./bin/apisix start`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

yaml_conf.apisix.node_listen = node_listen
elseif type(yaml_conf.apisix.node_listen) == "table" then
if type(yaml_conf.apisix.node_listen[1]) == "number" then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should check every item, what if the user mixes the integer and the table?

@@ -36,7 +36,8 @@ gRPC client -> APISIX -> gRPC/gRPCS server
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 use TLS‑encrypted HTTP/2 to expose gRPC service (default port 9443), so need to [config SSL certificate](https.md)
* attention: APISIX also support to expose gRPC service with plaintext HTTP/2 (default port 9081), which do not need to config SSL certificate, usually used to proxy gRPC service in intranet environment
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a configuration to show how we can do it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

conf/config.yaml Outdated
- port: 9080 # APISIX listening port
enable_http2: false # Disable to support HTTP proxy, nginx currently do not support HTTP and HTTP/2 with plaintext on the same port
# Details can be found in https://trac.nginx.org/nginx/ticket/816
- port: 9081 # APISIX listening port for HTTP/2 with plaintext
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't open a port for HTTP/2 by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@spacewander
Copy link
Member

Need to resolve the conflict, so that CI can start.

@sysulq sysulq force-pushed the feature/grpc-proxy-plaintext branch from e3f90e5 to 6d6cbf7 Compare February 8, 2021 07:04
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about "which doesn't rely on TLS/SSL"?

Copy link
Contributor Author

@sysulq sysulq Feb 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, done :-)

elseif type(yaml_conf.apisix.node_listen) == "table" then
local node_listen = {}
for index, value in ipairs(yaml_conf.apisix.node_listen) do
if type(value) == "number" then
Copy link
Contributor

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.

node_listen:
  - port: 9080
  - port: 9180
    enable_http2: true

Copy link
Member

@spacewander spacewander Feb 8, 2021

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.

Copy link
Contributor

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 the node_listen itself.

Copy link
Contributor Author

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:

node_listen:
    - 9080
    - 9081

@sysulq sysulq requested a review from tokers February 8, 2021 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants