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

[PIP-60] [Proxy-Server] Support SNI routing to support various proxy-server in pulsar #6566

Merged
merged 4 commits into from
Jun 4, 2020

Conversation

rdhabalia
Copy link
Contributor

@rdhabalia rdhabalia commented Mar 20, 2020

Motivation

Implementation of PIP-60
A proxy server is a go‑between or intermediary server that forwards requests from multiple clients to different servers across the Internet. The proxy server can act as a “traffic cop,” in both forward and reverse proxy scenarios, and adds various benefits in your system such as load balancing, performance, security, auto-scaling, etc.. There are already many proxy servers already available in the market which are fast, scalable and more importantly covers various essential security aspects that are needed by the large organization to securely share their confidential data over the network. Pulsar already provides proxy implementation PIP-1 which acts as a reverse proxy and creates a gateway in front of brokers. However, pulsar doesn’t provide support to use other proxies such as Apache traffic server (ATS), HAProxy, Nginx, Envoy those are more scalable and secured. Most of these proxy-servers support SNI ROUTING which can route traffic to a destination without having to terminate the SSL connection. Routing at layer 4 gives greater transparency because the outbound connection is determined by examining the destination address in the client TCP packets.
Netty supports sending SNI header on TLS handshake and this PR uses that Netty feature to send SNI header while connecting to proxy.

Modification

https://github.com/apache/pulsar/wiki/PIP-60:-Support-Proxy-server-with-SNI-routing#changes

Note: we have fully tested this changes with ATS proxy for both forward and reverse proxy scenarios. And I have also shared e2e example in PIP to use ATS proxy for client and broker integration.

@rdhabalia rdhabalia added this to the 2.6.0 milestone Mar 20, 2020
@rdhabalia rdhabalia self-assigned this Mar 20, 2020
@rdhabalia rdhabalia changed the title [Proxy-Server] Support SNI routing to support various proxy-server in pulsar [PIP-60] [Proxy-Server] Support SNI routing to support various proxy-server in pulsar Mar 25, 2020
@sijie sijie added the doc-required Your PR changes impact docs and you will update later. label Apr 8, 2020
Copy link
Member

@sijie sijie left a comment

Choose a reason for hiding this comment

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

@rdhabalia this is a great change! Overall the change looks good to me. I left some suggestions. PTAL.

authParams.put("tlsKeyFile", TLS_CLIENT_KEY_FILE_PATH);
clientBuilder.authentication(AuthenticationTls.class.getName(), authParams);

PulsarClient pulsarClient = clientBuilder.build();
Copy link
Member

Choose a reason for hiding this comment

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

Should we close the client or add @Cleanup annotation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes.. will add it.


try {
pulsarClient.newProducer().topic(topicName).create();
fail("should have failed due to invalid url");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fail("should have failed due to invalid url");
fail("should have failed due to non-tls url");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure. fixed it.

example = "pulsar+ssl://ats-proxy.example.com:4443 or "
+ "pulsar://ats-proxy.example.com:4080"
)
private String proxyServiceUrl;
Copy link
Member

Choose a reason for hiding this comment

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

based on my understanding, this service URL here can only be the binary protocol service URL correct? We can't use the HTTP-protocol service URL. If that's the case, can you document this setting in ClusterData and the related command-line tools? It might be good to add a validation to throw exceptions if it is not a binary protocol service url.

Copy link
Contributor Author

@rdhabalia rdhabalia Apr 15, 2020

Choose a reason for hiding this comment

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

yes, SNI works on layer-4 so, it requires binary URL for SNI routing. however, we added proxyUrl placeholder extensible by adding proxyType and right now we support SNI and in future we can have other type which can support HTTP as well. So, I think we don't want to restrict with binary url only. But I have a plan to add a separate document with examples of different proxy-solutions(ATS, Envoy) as multiple users are interested in this solution.

@rdhabalia
Copy link
Contributor Author

@sijie addressed the comments.

@sijie
Copy link
Member

sijie commented Apr 21, 2020

/pulsarbot run-failure-checks

@sijie
Copy link
Member

sijie commented May 18, 2020

@rdhabalia Can you rebase this pull request?

@codelipenghui
Copy link
Contributor

@rdhabalia could you please rebase this branch.

@rdhabalia
Copy link
Contributor Author

yes, I will rebase it soon.

@sijie
Copy link
Member

sijie commented May 26, 2020

/pulsarbot run-failure-checks

@rdhabalia rdhabalia force-pushed the proxy_sni branch 2 times, most recently from 0bb290d to 2a6628a Compare June 2, 2020 03:06
@codelipenghui
Copy link
Contributor

/pulsarbot run-failure-checks

@codelipenghui codelipenghui merged commit fb4a627 into apache:master Jun 4, 2020
huangdx0726 pushed a commit to huangdx0726/pulsar that referenced this pull request Aug 24, 2020
…server in pulsar (apache#6566)

### Motivation
Implementation of [PIP-60](https://github.com/apache/pulsar/wiki/PIP-60:-Support-Proxy-server-with-SNI-routing)
A proxy server is a go‑between or intermediary server that forwards requests from multiple clients to different servers across the Internet. The proxy server can act as a “traffic cop,” in both forward and reverse proxy scenarios, and adds various benefits in your system such as load balancing, performance, security, auto-scaling, etc.. There are already many proxy servers already available in the market which are fast, scalable and more importantly covers various essential security aspects that are needed by the large organization to securely share their confidential data over the network. Pulsar already provides proxy implementation PIP-1 which acts as a reverse proxy and creates a gateway in front of brokers. However, pulsar doesn’t provide support to use other proxies such as Apache traffic server (ATS), HAProxy, Nginx, Envoy those are more scalable and secured. Most of these proxy-servers support SNI ROUTING which can route traffic to a destination without having to terminate the SSL connection. Routing at layer 4 gives greater transparency because the outbound connection is determined by examining the destination address in the client TCP packets.
[Netty supports sending SNI header on TLS handshake](netty/netty#3801 (comment)) and this PR uses that Netty feature to send SNI header while connecting to proxy.

### Modification
https://github.com/apache/pulsar/wiki/PIP-60:-Support-Proxy-server-with-SNI-routing#changes

**Note:** we have fully tested this changes with ATS proxy for both forward and reverse proxy scenarios. And I have also shared e2e example in PIP to use ATS proxy for client and broker integration.
@rdhabalia rdhabalia deleted the proxy_sni branch September 21, 2020 19:56
@Anonymitaet Anonymitaet removed the doc-required Your PR changes impact docs and you will update later. label Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants