简体   繁体   English

Spring Boot Eureka - CSS 未显示在 Kubernetes/Ingress 上

[英]Spring Boot Eureka - CSS does not show up on a Kubernetes / Ingress

I am running Spring Boot Eureka on AKS (Azure Kubernetes) with a ingress to the the Eureka POD, there is no issue in loading the UI but the CSS and the wor.js does not load.我在 AKS(Azure Kubernetes)上运行 Spring Boot Eureka,并进入 Eureka POD,加载 UI 没有问题,但未加载 CSS 和 wor.js。

application.properties应用程序属性

eureka:
  dashboard:
    enabled: true
    path: /webui

Ingress入口

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: discovery-ingress
  namespace: default
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /$2
    nginx.ingress.kubernetes.io/use-regex: "true"
spec:
  rules:
  - http:
      paths:
      - path: /discovery(/|$)(.*)
        backend:
         serviceName: discovery
         servicePort: 8761

I am new to Ingress so trying to figure out how to map the:我是 Ingress 的新手,所以想弄清楚如何映射:

   <link rel="stylesheet" href="eureka/css/wro.css">

and the

    <script type="text/javascript" src="eureka/js/wro.js" ></script>

so that he default ingress backend does not give a 404.这样他的默认入口后端就不会给出 404。

Typically Ingress gives you an external endpoint like eureka.example.com so your javascript should be loaded in the form of https://eureka.example.com/js/wro.js通常 Ingress 会给你一个像eureka.example.com这样的外部端点,所以你的 javascript 应该以https://eureka.example.com/js/wro.js的形式加载

Also please use https://github.com/spring-cloud/spring-cloud-kubernetes so that spring-cloud and Kubernetes do not step on each other toes.还请使用https://github.com/spring-cloud/spring-cloud-kubernetes以便 spring-cloud 和 Kubernetes 不会互相踩踏。

I had the same issue but I'm hosting my eureka server with Nginx, the following config solved this issue.我有同样的问题,但我用 Nginx 托管我的 eureka 服务器,以下配置解决了这个问题。

  location /eureka/ {
    proxy_pass          http://localhost:8761/eureka/;
    proxy_redirect      http://localhost:8761/eureka/ https://example.com;
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM