Skip to content

feat: support listen http2 with plaintext#3547

Merged
spacewander merged 13 commits into
apache:masterfrom
sysulq:feature/grpc-proxy-plaintext
Feb 19, 2021
Merged

feat: support listen http2 with plaintext#3547
spacewander merged 13 commits into
apache:masterfrom
sysulq:feature/grpc-proxy-plaintext

Conversation

@sysulq

@sysulq sysulq commented Feb 7, 2021

Copy link
Copy Markdown
Contributor

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
Comment thread apisix/cli/ops.lua Outdated
local node_listen = {{port = yaml_conf.apisix.node_listen}}
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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?

Comment thread t/core/config-default.t



=== TEST 5: support listen multiple ports with array

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread conf/config.yaml Outdated
# If the configured environment variable can't be found, an error will be thrown.
apisix:
node_listen:
- port: 9080 # APISIX listening port

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread apisix/cli/ops.lua Outdated
local node_listen = {{port = yaml_conf.apisix.node_listen}}
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
Copy Markdown
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?

Comment thread doc/grpc-proxy.md Outdated
* 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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Comment thread doc/grpc-proxy.md Outdated

* 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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"?

@sysulq sysulq Feb 8, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Alright, done :-)

Comment thread apisix/cli/ops.lua
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
Copy Markdown
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

@spacewander spacewander Feb 8, 2021

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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