【问题标题】:JHipster application running in Docker container - Websocket error在 Docker 容器中运行的 JHipster 应用程序 - Websocket 错误
【发布时间】:2016-11-16 10:45:30
【问题描述】:

我尝试在 Docker 容器内的服务器上运行基于 JHipster 的小型应用程序时遇到问题。 问题出在 Websocket 连接上: VM1772:35 WebSocket connection to 'ws://example.com/websocket/tracker/011/oxjwhn1s/websocket?access_token=ey…_TUTlIQeihPamU9Cr4AELuIqgnxZlAExhpBzRGwTtSBsQtC1_uMmwttUYgMmvhdbZhMLCS2RoA' failed: Error during WebSocket handshake: Unexpected response code: 400 (我更改了实际域名)

应用在使用 maven 目标 docker:build 构建的 Docker 容器中运行。 为了只能通过域名访问,我使用了也在 Docker 容器 (https://github.com/jwilder/nginx-proxy) 内运行的 nginx 反向代理,我认为在 nginx 配置中可以设置标头转发:

proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;

为了让它正常工作,我缺少什么?

【问题讨论】:

    标签: spring-boot jhipster spring-websocket


    【解决方案1】:

    我将通过接下来的步骤来定位问题:

    • 尝试以独立方式运行应用程序,以确保问题不在应用程序中。
    • 尝试在没有代理的情况下在 docker 中运行应用程序
    • 最后,如果这两个步骤有效,然后尝试在代理后面运行应用程序,以确保您拥有正确的代理配置。

    如果这最后一步没问题,那么它需要是 docker 配置。为了给您更多选择,最好从您的日志中获得更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-29
      • 2016-03-26
      • 2018-07-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多