【问题标题】:How to write dispatch.yaml when having three services in APP ENGINE in GCP在GCP的APP ENGINE中有三个服务时如何编写dispatch.yaml
【发布时间】:2021-12-02 13:58:22
【问题描述】:

我在三个不同的文件夹中有三个服务,

app.yaml:(默认服务) (https://cool-adviser-307212.oa.r.appspot.com/)(https://abanoub-ayoub.com/)

runtime: nodejs16
handlers: 
- url: /
  static_files: build/index.html
  upload: build/index.html
- url: /
  static_dir: build

ui-challenge.yaml: (https://ui-challenge-dot-cool-adviser-307212.oa.r.appspot.com/)

  runtime: nodejs16
  service: ui-challenge
  handlers:
  - url: /
    static_files: build/index.html
    upload: build/index.html
  - url: /(.*)$
    static_files: build/\1
    upload: build/(.*)

test-service.yaml: (https://test-service-dot-cool-adviser-307212.oa.r.appspot.com/)

  runtime: nodejs16
  service: test-service
  handlers:
  - url: /
    static_files: build/index.html
    upload: build/index.html
  - url: /(.*)$
    static_files: build/\1
    upload: build/(.*)

在根文件夹中,我有 dispatch.yaml

dispatch:
- url: "abanoub-ayoub.com/"
  service: default
- url: "*/ui-challenge"
  service: ui-challenge
- url: "*/test"
  service: test-service

但是当我导航到 (https://abanoub-ayoub.com/ui-challenge) 或 (https://abanoub-ayoub.com/task) 时,我收到 404 错误,但我需要能够导航到这些服务。

更新

Dispatch routes

谢谢!

【问题讨论】:

    标签: node.js google-cloud-platform cloud


    【解决方案1】:

    您可以使用应用引擎设置从 GCP 应用引擎控制台为您的网站设置域,还可以创建子域记录以重定向到特定的应用引擎服务

    例子,

    参考:https://cloud.google.com/appengine/docs/standard/python3/mapping-custom-domains

    dispatch:
    - url: "simple-sample.uc.r.appspot.com/"
      service: default
    - url: "*/ui-challenge/"
      service: ui-challenge
    - url: "*/test/"
      service: test-service
    

    【讨论】:

    • 感谢您回答这个问题。但我想导航到 (abanoub-ayoub.com/ui-challenge) 和 (abanoub-ayoub.com/task) 并加载相关服务。是否可以使用 dispatch.yaml 文件?我认为是。
    • 是的,同样的方式你需要创建不同的服务来进行 ui 挑战并使用 app.yaml 中的服务参数进行测试,然后使用 dispatch yaml t
    • 它对我不起作用,你有什么建议解决这个问题?
    猜你喜欢
    • 2019-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    • 2010-09-24
    • 2020-11-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多