Vault UI API 在初次成功后给出 ERR_CONNECTION_RESET 失败

问题描述 投票:0回答:1

我最初在 UI 中获得所有 API 都是成功的,然后一旦我创建了新的 raft 集群,我在 UI 中的 API 就会收到 ERR_CONNECTION_RESET。

我的Vault服务器在实验室环境中作为docker容器运行,并在连接到VPN后尝试从笔记本电脑访问它。由于很少有 API 调用成功通过,我认为这不是防火墙或 VPN 问题。

我能够成功从 cli 中解封。

我的 Vauly.hcl 文件

    cluster_addr  = "https://127.0.0.1:8201"
api_addr      = "https://127.0.0.1:8200"
disable_mlock = true

storage "raft" {
  path = "/path/to/raft/data"
  node_id = "raft_node_id"
}

# Listener on port 8200 (adjust as needed)
listener "tcp" {
  address = "0.0.0.0:8200"
  tls_disable = true  # Disable TLS for development (enable for production)
}

# Enable the UI
ui = true
# Enable userpass authentication (for development purposes)
auth "userpass" {
  type = "userpass"
  users {
    username = "vault_user"
    password = "vault_password"
  }
}

当我尝试从 Web-UI 解封时,我遇到了同样的问题

但是我能够从 CLI 成功解封并连接。

/ # vault operator unseal Vv1qKhQ0So......vsZNLgnSBmwQ
Key                Value
---                -----
Seal Type          shamir
Initialized        true
Sealed             true
Total Shares       5
Threshold          3
Unseal Progress    1/3
Unseal Nonce       f7d8706f-9623-38a0-d454-2c4564749d17
Version            1.13.3
Build Date         2023-06-06T18:12:37Z
Storage Type       raft
HA Enabled         true
/ #

路线:2

我尝试使用以下命令运行最新的保管库容器

 docker pull hashicorp/vault
docker run --cap-add=IPC_LOCK -e 'VAULT_LOCAL_CONFIG={"storage": {"file": {"path": "/vault/file"}}, "listener": [{"tcp": { "address": "0.0.0.0:8200", "tls_disable": true}}], "default_lease_ttl": "168h", "max_lease_ttl": "720h", "ui": true}' -p 8200:8200 hashicorp/vault server

我只设置相同的 ERR_CONNECTION_RESET 问题

docker security devops hashicorp-vault
1个回答
0
投票

由于您可以从 CLI 解封 Vault,因此问题可能不在于 Vault 服务器本身,而在于网络配置,例如关于 VPN 的 Docker 容器网络配置方式的问题。

                 +-----------------+
                 |   [Laptop]      |
                 |  Vault UI       |
                 +--------|--------+
                          |
+-------------------------|-------------------------+
| [Docker Container]                                |
|  +------------------+        +-----------------+  |
|  |  Vault Server    | <----> |  Vault Storage  |  |
|  |  Listener: 8200  |        |  Raft Protocol  |  |
|  +------------------+        +-----------------+  |
+--------------------------------------------------+

您已将侦听器配置为绑定到

0.0.0.0:8200
并禁用 TLS。确保您的网络上不存在可能干扰此端口上的流量的冲突或安全策略,尤其是当您通过 VPN 连接时。

cluster_addr
api_addr
设置为
127.0.0.1
。这意味着它们只能在容器内本地访问。如果您尝试从笔记本电脑访问 UI,则将无法访问这些地址。这些应设置为 VPN 内 Docker 主机的实际 IP 地址或可解析主机名。

您的 Vault 配置可能是:

listener "tcp" {
  address     = "0.0.0.0:8200"
  cluster_address = "0.0.0.0:8201"
  tls_disable = true  # Should be false in production
}

# The addresses below need to be accessible by all nodes and clients
api_addr = "http://<Docker-Host-IP>:8200"
cluster_addr = "http://<Docker-Host-IP>:8201"

storage "raft" {
  path    = "/vault/data"
  node_id = "node1"
}

即:

[Laptop via VPN]
    |
    v
[Docker Host IP] (accessible via VPN)
    |
[Container running Vault]
    | <- Listens on all interfaces 0.0.0.0:8200 (accessible via Docker Host IP)
    |
[Vault Raft Storage] (within the container)
© www.soinside.com 2019 - 2024. All rights reserved.