首页 > 解决方案 > 通过别名在另一个容器的反向代理后面访问 Docker 容器

问题描述

我正在尝试在包含 Cypress 的 Docker 容器内使用 ZAP-Docker 作为 yml 文件服务(端到端测试执行)。我使用 ZAP 作为反向代理,其想法是将流量从赛普拉斯转移到 ZAP。但是,正如您可以想象的那样,我不能使用 zap 容器的 IP 地址。所以我正在尝试使用别名的解决方案。

这是 yml 文件的一部分:

services:
  - name: owasp/zap2docker-stable:latest
    alias: zap
    ports:
        - "8092:8092"
    entrypoint: ["zap.sh"]
    command: ["-daemon", "-port", "8092", "-host", "0.0.0.0", "-config", "api.disablekey=true", "-config", "api.addrs.addr.name=.*", "-config", "api.addrs.addr.regex=true"]

这是我用来将流量转移到 ZAP 容器的命令(使用它的别名)

HTTP_PROXY=http://zap:8092 npx cypress run

赛普拉斯文档在这里

不幸的是,我通过执行测试从赛普拉斯得到了这个错误:

Cypress could not verify that this server is running:

  > https://app.cloud

We are verifying this server because it has been configured as your `baseUrl`.

Cypress automatically waits until your server is accessible before running tests.

标签: dockergitlabreverse-proxyaliascypress

解决方案


推荐阅读