我在 Google App Engine 上部署了一個帶有 2 個服務的 PHP 應用程式:admin 和 api。
我使用組態檔來路由請求。
我的問題是我無法將請求路由到我的服務。只到默認。
這是結構:
|-- admin
|-- public
|-- index.php
|-- admin.yaml
|-- API
|-- api
|-- index.php
|-- api.yaml
|-- dispatch.yaml
|-- index.php
dispatch.yaml:
dispatch:
# Send all api traffic to the API.
- url: "*/API/api/*"
service: api
# Send all admin traffic to the admin.
- url: "*/admin/public/*"
service: admin
# Default service serves simple hostname request.
- url: "*/*"
service: default
管理員/管理員.yaml:
runtime: php73
service: admin
handlers:
- url: /admin/public/.*
script: /admin/public/index.php
API/api.yaml:
runtime: php73
service: api
handlers:
- url: /API/api/.*
script: /API/api/index.php
索引.php: echo "Not found";
管理/公共/index.php: echo "Welcome to admin service";
API/api/index.php: echo "Welcome to api service";
當我發送請求時:https://SERVICE_ID-dot-PROJECT_ID.REGION_ID.r.appspot.com或者https://PROJECT_ID.REGION_ID.r.appspot.com回應是預期的:未找到。
但是當我發送請求時:https://SERVICE_ID-dot-PROJECT_ID.REGION_ID.r.appspot.com/API/api/或者https://PROJECT_ID.REGION_ID.r.appspot.com/API/api/回應是一個error code 500而不是:Welcome to api service。
問題是什么 ?配置 ?請求網址?其他 ?
uj5u.com熱心網友回復:
問題出在 yaml 檔案中:
新的 dispatch.yaml
dispatch:
# Send all api traffic to the API.
- url: "SERVICE_ID-dot-PROJECT_ID.REGION_ID.r.appspot.com"
service: api
# Send all admin traffic to the admin.
- url: "SERVICE_ID-dot-PROJECT_ID.REGION_ID.r.appspot.com"
service: admin
# Default service serves simple hostname request.
- url: "PROJECT_ID.REGION_ID.r.appspot.com"
service: default
新的 admin/admin.yaml:
runtime: php73
service: admin
handlers:
- url: /.*
script: /admin/public/index.php
新的 API/api.yaml:
runtime: php73
service: api
handlers:
- url: /.*
script: /API/api/index.php
沒有更多的路由問題。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/361607.html
標籤:谷歌应用引擎
