如何将Ngrok隧道传输到流道容器

时间:2020-08-31 15:47:39

标签: docker ngrok

我正在尝试使用ngrok进入正在运行的docker容器。原因是auth项目是我们用于oauth的项目,我希望能够(在测试时)将我的设备本地连接到它。如果我在本地运行auth项目并为其定义一个特定的URL,例如127.0.0.1:{w.e port i want},它确实可以正确连接,但是我想通过ngrok做到这一点。我的ngrok.yml如下所示:

authtoken: {token removed for security reasons}
tunnels:
  authentication:
    proto: http
    addr: 44136
    subdomain: mkovalskyauth
    host_header: localhost

从docker compose项目启动auth项目的方式如下:

  authentication.company:
    image: authentication.company
    environment:
      DROPVIEWS: ${DROPVIEWS}   
    build:
      context: .
      dockerfile: Company.Authentication/Dockerfile
    ports:
      - "44136:44136"

我已经添加了端口部分,因为我们当然需要将端口公开到互联网,以便docker能够正确连接到它。当我使用ngrok start --all运行ngrok时(我在Windows上),当我导航到URL mkovalskyauth.ngrok.io时,出现502错误。不过,有趣的是,我的docker compose还使用预期的mongo端口27017定义了一个mongodb容器,如果我要更新ngrok.yml以指向该端口并导航至该端口,那么我将在浏览器中得到正确的响应“似乎您在连接到mongo时正在使用html”,因此该隧道可以正常工作。我错过了哪一步?

0 个答案:

没有答案