Hypertext Transfer Protocol Secure (HTTPS) is a security-enhanced version of HTTP. HTTPS works with Secure Socket Layer (SSL) to ensure the security of data transmission. HTTPS uses HTTP for communications. SSL is used to encrypt the data. To ensure data security, we recommend that you enable HTTPS. This topic describes how to enable HTTPS for an Elasticsearch cluster.

Prerequisites

  • An Alibaba Cloud Elasticsearch cluster is created.

    For more information, see Create an Alibaba Cloud Elasticsearch cluster.

  • A client node is purchased for the Elasticsearch cluster if the cluster meets the related version requirements. For more information, see Can I enable HTTPS for an Elasticsearch cluster that does not contain client nodes?

    You can purchase a client node when you create an Elasticsearch cluster or upgrade the configuration of an Elasticsearch cluster. For more information, see Parameters on the buy page and Upgrade the configuration of a cluster.

  • Modify the code of your client that you want to use to access the Elasticsearch cluster. If you do not modify the code, you cannot use the client to access the cluster.
    In the following code, the REST client of open source Elasticsearch is used. After you enable HTTPS, you must include the https parameter in HttpHost, such as new HttpHost("es-cn-xxxxx.elasticsearch.aliyuncs.com", 9200, "https"));. Sample code:
    • Code before HTTPS is enabled
      final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
              credentialsProvider.setCredentials(AuthScope.ANY,
                  new UsernamePasswordCredentials("elastic", "Your password"));
      RestClientBuilder restClientBuilder = RestClient.builder(
                  new HttpHost("es-cn-xxxxx.elasticsearch.aliyuncs.com", 9200));
              RestClient restClient = restClientBuilder.setHttpClientConfigCallback(
                  new RestClientBuilder.HttpClientConfigCallback() {
                      @Override
                      public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
                          return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
                      }
                  }).build();
    • Code after HTTPS is enabled
      final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
              credentialsProvider.setCredentials(AuthScope.ANY,
                  new UsernamePasswordCredentials("elastic", "Your password"));
      RestClientBuilder restClientBuilder = RestClient.builder(
                  new HttpHost("es-cn-xxxxx.elasticsearch.aliyuncs.com", 9200, "https"));
              RestClient restClient = restClientBuilder.setHttpClientConfigCallback(
                  new RestClientBuilder.HttpClientConfigCallback() {
                      @Override
                      public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
                          return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
                      }
                  }).build();

Procedure

  1. Log on to the Alibaba Cloud Elasticsearch console.
  2. In the left-side navigation pane, click Elasticsearch Clusters.
  3. Navigate to the desired cluster.
    1. In the top navigation bar, select the resource group to which the cluster belongs and the region where the cluster resides.
    2. On the Elasticsearch Clusters page, find the cluster and click its ID.
  4. In the left-side navigation pane of the page that appears, click Security.
  5. In the Network Settings section of the page that appears, turn on the HTTPS switch.
    Warning During the process of enabling or disabling HTTPS, the services that run on the cluster are interrupted, and the Elasticsearch cluster is restarted. Make sure that the enabling or disabling operation does not affect your services.
  6. In the Note dialog box, select the I have created an HTTPS client check box and click OK.
    Note
    Note If you have not purchased client nodes, the system prompts you to purchase client nodes when you turn on the HTTPS switch. You must follow the instructions to purchase client nodes.
    After you confirm the operation, the Elasticsearch cluster is restarted. You can view the restart progress in the Tasks dialog box. After the restart is complete, you can access the Elasticsearch cluster over HTTPS.

FAQ

Q: How do I obtain the required certificates after I enable HTTPS for my Elasticsearch cluster?

A: To ensure the security and stability of Alibaba Cloud Elasticsearch clusters, Alibaba Cloud Elasticsearch does not provide certificates for the public.