启用端点404错误代码 - 部署的应用程序

发布于 2025-02-10 22:07:52 字数 1770 浏览 1 评论 0原文

我正在云中部署我的应用程序,在03架上的群集内部:

  1. 一个吊舱:后端 - Quarkus
  2. One Pod:Frontend -Angular
  3. One Pod:db -Postgres

后端后端具有03个端点:

  1. 一个端点:GraphQl
  2. 两个端点:REST

POD被公开:

  1. 后端:clusterip
  2. db:clusterip
  3. frontend:nodePort

我有一个NGNIX Web Server& 02入口体现;一个用于后端,另一个用于前端:

1-后端 - 印第安纳斯:

    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: mcs-thirdparty-back-ingress
      namespace: namespace
      annotations:
        nginx.ingress.kubernetes.io/use-regex: "true"
    spec:
      ingressClassName: nginx-internal
      rules:
      - host: backend.exemple.com
        http:
          paths:
          - path: /
            backend:
              service:
                name: mcs-thirdparty-backend
                port:
                  number: 8080
            pathType: Prefix

2-前端 - ingress:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: mcs-thirdparty-ingress
  namespace: namespace
spec:
  ingressClassName: nginx-internal
  rules:
  - host: bilels.exemple.com
    http:
      paths:
      - path: /
        backend:
          service:
            name: mcs-thirdparty-frontend
            port:
              number: 80
        pathType: Prefix

GraphQl端点/请求;前端可以与后端正确通信并获取所需的数据。 当我运行POST请求以从服务器获取访问权限(REST ENDPOINT)时,我会收到404错误代码。

错误屏幕截图在这里

我试图在后端 - ingress清单中添加几个更改404 - 路径:/(.FARING> - 路径: /*< /code> - 路径: /响应< /code>

I'm deploying my application in the cloud, inside a cluster on 03 pods:

  1. one pod: backend - Quarkus
  2. one pod: frontend - Angular
  3. one pod: DB - Postgres

The backend has 03 endpoints:

  1. One endpoint: GraphQL
  2. Two endpoints: Rest

The pods are exposed:

  1. backend: ClusterIp
  2. DB: ClusterIp
  3. frontend: NodePort

I have an Ngnix web server & 02 ingress manifests; one for the backend and a second for the frontend:

1- backend-ingress:

    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: mcs-thirdparty-back-ingress
      namespace: namespace
      annotations:
        nginx.ingress.kubernetes.io/use-regex: "true"
    spec:
      ingressClassName: nginx-internal
      rules:
      - host: backend.exemple.com
        http:
          paths:
          - path: /
            backend:
              service:
                name: mcs-thirdparty-backend
                port:
                  number: 8080
            pathType: Prefix

2- frontend-ingress:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: mcs-thirdparty-ingress
  namespace: namespace
spec:
  ingressClassName: nginx-internal
  rules:
  - host: bilels.exemple.com
    http:
      paths:
      - path: /
        backend:
          service:
            name: mcs-thirdparty-frontend
            port:
              number: 80
        pathType: Prefix

For the GraphQL endpoint/request; the frontend can correctly communicate with the backend and fetchs the required data.
When I run the POST request to fetch the accessToken from the server (Rest Endpoint), I receive the 404 error code.

The error screenshot is here

I tried to add several changes in the backend-ingress manifest, but always 404
- path: /(.*)
- path: /*
- path: /response

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你又不是我 2025-02-17 22:07:53

您的后端应用程序是否有可能在端口8080上提供?

如果这是真的,您应该访问backend.exemple.com:8080/response,假设wendment> wenders是您配置的路径的名称。

使Swagger-UI可以测试

您可以在Quarkus应用程序上启用Swagger-UI,以确保您的端点。

为此,您必须将其添加到您的pom.xml

    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-smallrye-openapi</artifactId>
    </dependency>

并在您的application.properties上设置此此功能(在您时能够访问Swagger-UI不在开发模式下运行):

# If this should be included every time. By default this is only included when the application is running in dev mode.
quarkus.swagger-ui.always-include=true

完成此操作,您可以访问:your-path:your-port-number/q/swagger-ui .com:8080/Q/Swagger-UI

Is it possible that your backend application is providing on port 8080?

If this is true, you should access backend.exemple.com:8080/response , supposing that response is the name of the path you have configured.

Enabling swagger-ui to test

You could enable the swagger-ui on your quarkus application to make sure of your endpoints.

To do it, you must add this to your pom.xml:

    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-smallrye-openapi</artifactId>
    </dependency>

And set this on your application.properties (to be able to access the swagger-ui when you're not running on dev mode):

# If this should be included every time. By default this is only included when the application is running in dev mode.
quarkus.swagger-ui.always-include=true

With this done, you can access the swagger-ui at: your-path:your-port-number/q/swagger-ui, like backend.exemple.com:8080/q/swagger-ui

浅紫色的梦幻 2025-02-17 22:07:52

我认为我设法在Ryan Dawson的帮助下做出了另一种诊断方法。
我确实在当地的后端POD Portforaward并从本地请求,然后发现有一个500错误代码 - &gt;这意味着该请求与API要求不符合:在前端我是错误的上下文类型。

- &gt;因此,入口配置已经处于良好状态。

I thinks that I managed to make another Diagnotic method wiht the help for Ryan Dawson.
I did PortForaward the backend pod and request from the locally, then I found that there is a 500 error code --> meaning that the request was not matching the api requirements: in the frontend I was sendign the wrong context type.

--> so the ingress config is already in a good shape.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文