리전 ID
REGION_ID는 앱을 만들 때 선택한 리전을 기준으로 Google에서 할당하는 축약된 코드입니다. 일부 리전 ID는 일반적으로 사용되는 국가 및 주/도 코드와 비슷하게 표시될 수 있지만 코드는 국가 또는 주/도와 일치하지 않습니다. 2020년 2월 이후에 생성된 앱의 경우 REGION_ID.r이 App Engine URL에 포함됩니다. 이 날짜 이전에 만든 기존 앱의 경우 URL에서 리전 ID는 선택사항입니다.
리전 ID에 대해 자세히 알아보세요.
dispatch.yaml을 사용하면 라우팅 규칙을 재정의할 수 있습니다.
dispatch.yaml을 사용하면 URL의 경로 또는 호스트 이름에 따라 수신 요청을 특정 서비스(이전 명칭은 모듈)로 보낼 수 있습니다.
자세한 내용은 요청 라우팅 방법을 참조하세요.
앱에는 dispatch.yaml 파일 하나만 포함될 수 있으며 이 파일의 라우팅 규칙은 앱의 모든 서비스 및 버전에 적용됩니다.
라우팅 규칙은 크론 파일에 사용되는 URL에도 적용됩니다.
디스패치 파일 배포
dispatch.yaml 파일은 소스 코드 디렉터리의 어디에나 상주할 수 있습니다.
현재 제공 중인 버전을 변경하지 않고 디스패치 구성 파일을 배포하려면 디스패치 파일이 포함된 디렉터리에서 환경에 따라 다음 명령어 중 하나를 사용합니다.
gcloud
gcloud app deploy dispatch.yaml
Maven
mvn appengine:deployDispatch dispatch.yaml
Gradle
gradle appengineDeployDispatch dispatch.yaml
IDE
IntelliJ 또는 Eclipse를 사용하는 경우 배포 양식을 사용하여 배포할 개별 구성 파일을 선택합니다.
배포 명령어에 대한 자세한 내용은 앱 배포를 참조하세요.
구문
dispatch.yaml 파일의 루트 요소는 dispatch:이며 다음 하위 요소로 지정된 라우팅 정의 목록을 포함합니다.
디스패치 파일에 정의하는 규칙에는 '.' 표기법으로 하위 도메인을 구분하는 HTTP URL 패턴을 사용해야 합니다. HTTPS '-dot-' 표기법을 사용하여 정의된 URL은 지원되지 않습니다.
디스패치 규칙은 순서에 따라 달라지며 URL과 일치하는 첫 번째 규칙만 적용됩니다.
| 요소 | 설명 |
|---|---|
service |
|
url |
팁:
|
예
다음은 요청을 https://simple-sample.uc.r.appspot.com으로, https://simple-sample.uc.r.appspot.com/favicon.ico와 같은 요청을 default 서비스로 라우팅하는 샘플 디스패치 파일입니다. 모든 정적 콘텐츠는 default 서비스에서 제공됩니다. https://simple-sample.uc.r.appspot.com/mobile/과 같은 모바일 요청은 모바일 프런트엔드로 라우팅되고 https://simple-sample.uc.r.appspot.com/work/와 같은 작업자 요청은 정적 백엔드로 라우팅됩니다.
예:
dispatch:
# Default service serves the typical web resources and all static resources.
- url: "*/favicon.ico"
service: default
# Default service serves simple hostname request.
- url: "simple-sample.uc.r.appspot.com/"
service: default
# Send all mobile traffic to the mobile frontend.
- url: "*/mobile/*"
service: mobile-frontend
# Send all work to the one static backend.
- url: "*/work/*"
service: static-backend
가능한 많은 요청과 일치하는 일반적인 라우팅 규칙을 선호한다면 보다 광범위한 규칙을 정의하면 됩니다.
예:
# Send any path that begins with “simple-sample.uc.r.appspot.com/mobile” to the mobile-frontend service.
- url: "simple-sample.uc.r.appspot.com/mobile*"
service: mobile-frontend
# Send any domain/sub-domain with a path that starts with “work” to the static backend service.
- url: "*/work*"
service: static-backend
보다 엄격한 표현식을 작성할 수도 있습니다.
예:
# Matches the path "/fun", but not "/fun2" or "/fun/other"
- url: "*/fun"
service: mobile-frontend
# Matches the hostname 'customer1.myapp.com', but not '1.customer1.myapp.com.
- url: "customer1.myapp.com/*"
service: static-backend
수신 도메인 요청을 서비스로 전달하는 규칙을 만들 수 있습니다. 다음 규칙은 'customer1.myapp.com'에서 기본 서비스로 들어오는 요청과 하위 도메인에서 정적 백엔드 서비스로 들어오는 요청을 라우팅합니다.
예:
# Matches the domain name 'customer1.myapp.com' and directs all the request to default service
- url: "customer1.myapp.com/*"
service: default
# Matches all the subdomains of 'customer1.myapp.com' and directs all the request to static-backend service
- url: "*.customer1.myapp.com/*"
service: static-backend
한도
디스패치 파일에는 최대 20개의 라우팅 규칙을 포함할 수 있습니다. URL 문자열을 지정할 때 호스트 이름 및 경로가 100자(영문 기준)를 초과하면 안 됩니다.
모든 디스패치 규칙 삭제
모든 디스패치 규칙을 삭제하는 방법은 다음과 같습니다.
dispatch.yaml파일의 콘텐츠를 다음과 같이 수정합니다.dispatch: []dispatch.yaml파일을 App Engine에 배포합니다.