OpenSearch docker 实例仅允许 HTTPS 连接

OpenSearch docker instance only allowing HTTPS connections

我正在尝试在我的本地计算机上配置 OpenSearch,并使用以下配置通过 docker-compose 部署它:

opensearch:
    image: opensearchproject/opensearch:1.0.0
    restart: unless-stopped
    ports:
      - "9200:9200"
      - "9300:9300"
    environment:
      discovery.type: single-node

实例成功启动,但是当尝试通过 Web 界面访问它时,它只接受具有默认基本身份验证凭据 (admin:admin) 的 HTTPS 连接。即

https://localhost:9200 要求我输入管理员凭据,然后 returns 预期的响应:

{
  "name" : "a39dcf825899",
  "cluster_name" : "docker-cluster",
  "cluster_uuid" : "d2ZBZDQRTyG6SvYlCmX3Iw",
  "version" : {
    "distribution" : "opensearch",
    "number" : "1.0.0",
    "build_type" : "tar",
    "build_hash" : "34550c5b17124ddc59458ef774f6b43a086522e3",
    "build_date" : "2021-07-02T23:22:21.383695Z",
    "build_snapshot" : false,
    "lucene_version" : "8.8.2",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "The OpenSearch Project: https://opensearch.org/"
}

然而,当尝试通过 HTTP 连接到实例时,我得到一个空响应:

在 chrome:

在单独的 Docker 容器(同一 docker-compose.yml 的一部分)中的 Django 实例 运行 上使用 OpenSearch Python 客户端:

opensearchpy.exceptions.ConnectionError: ConnectionError(('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))) caused by: ProtocolError(('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')))

作为参考,我用来将 OpenSearch Python 客户端连接到 OpenSearch 实例的代码是:

cls._os_client = OpenSearch(
                [{"host": 'opensearch', "port": '9200'}],
                use_ssl=False,
                verify_certs=False,
                ssl_assert_hostname=False,
                ssl_show_warn=False
            )

如何配置 OpenSearch 以允许不安全的 HTTP 连接?

您可以 disable security,只需将 DISABLE_SECURITY_PLUGIN=true 添加到您的环境即可。