Cloud Foundry css 文件 returns 502 错误网关:注册端点无法处理请求

Cloud Foundry css file returns 502 Bad Gateway: Registered endpoint failed to handle the request

我将 spring 启动应用程序 VUE frontend 推送到 Cloud Foundry。当我向静态文件 (css/img/js) 发送请求时,例如 https://bd-contacts-gateway.cfapps.io/js/chunk-vendors.8b8c1d1d.js

我明白了

502 Bad Gateway: Registered endpoint failed to handle the request.

在我的 spring 引导应用程序中,我在 src/main/resources/jssrc/main/resources/css, src/main/resources/img

中有静态文件

这是我推到CF

时的manifest.yml
---

applications:

- name: bd-contacts-gateway

  memory: 1024M

  buildpack: staticfile_buildpack

  routes:

  - route: bd-contacts-gateway.cfapps.io

编辑:

这是调用 swagger-ui 时从 cf 日志中提取的 URL:

2019-09-11T11:34:04.60+0200 [RTR/10] OUT bd-contacts-gateway.cfapps.io
- [2019-09-11T09:34:04.491+0000] "GET /swagger-ui.html HTTP/1.1" 502 0 67 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Safari/605.1.15" "10.10.66.115:63512" "10.10.148.61:61150" x_forwarded_for:"80.242.35.228, 10.10.66.115" x_forwarded_proto:"https" vcap_request_id:"6ccc526a-00c6-4a80-46c1-4c4eee6fcab7" response_time:0.115106066 app_id:"b5dc7fb4-a52a-4997-93cb-9ed40a158bcc" app_index:"0" x_b3_traceid:"3b50452335bafcf9" x_b3_spanid:"3b50452335bafcf9" x_b3_parentspanid:"-" b3:"3b50452335bafcf9-3b50452335bafcf9"

我找到了解决方案。我必须在我的 application-cloud.yml 属性中添加 remote_ip_header 和 protocol_header。像这样:

server:
  port: 8080
  tomcat:
    remote_ip_header: x-forwarded-for
    protocol_header: x-forwarded-proto

eureka:
  client:
    serviceUrl:
      defaultZone: http://bd-contacts-eureka.cfapps.io/eureka/
  instance:
    hostname: ${vcap.application.uris[0]}
    nonSecurePort: 80