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



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

我得到

502 错误的网关:已注册的终结点无法处理请求。

在我的 Spring 启动应用程序中,我在src/main/resources/js中拥有静态文件,src/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 URL 时从 cf 日志中提取的:

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"

我找到了解决方案。我不得不在我的应用程序 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

相关内容

  • 没有找到相关文章

最新更新