Cloud Endpoints에 필요한 구성이 포함된 nginx.conf 파일로 시작합니다. 샘플 nginx.conf로 시작하거나, 이미 ESP를 배포한 경우에는 SSH를 통해 ESP 컨테이너에 연결한 후 /etc/nginx/endpoints/ 디렉터리에서 nginx.conf 파일을 복사할 수 있습니다.
애플리케이션에 필요한 CORS 옵션을 nginx.conf에 추가합니다. NGINX의 CORS 예시를 시작점으로 사용할 수 있습니다.
커스텀 nginx.conf 파일 경로와 함께 --nginx_config 옵션을 사용하여 ESP를 시작합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[[["\u003cp\u003eYou can configure the Extensible Service Proxy (ESP) to support CORS, as described in the documentation for adding CORS support to ESP.\u003c/p\u003e\n"],["\u003cp\u003eIf ESP options don't meet your application's CORS needs, you can customize CORS by adding options directly to ESP's \u003ccode\u003enginx.conf\u003c/code\u003e configuration file.\u003c/p\u003e\n"],["\u003cp\u003eTo add custom CORS options, begin with a \u003ccode\u003enginx.conf\u003c/code\u003e file required by Cloud Endpoints, such as the sample one, or by retrieving it from a deployed ESP container.\u003c/p\u003e\n"],["\u003cp\u003eAfter adding your custom CORS settings to \u003ccode\u003enginx.conf\u003c/code\u003e, start ESP using the \u003ccode\u003e--nginx_config\u003c/code\u003e option, pointing to your modified configuration file.\u003c/p\u003e\n"]]],[],null,["# Creating a Custom nginx.conf to Support CORS\n\nOpenAPI \\| [gRPC](/endpoints/docs/grpc/custom-cors-nginx \"View this page for the Cloud Endpoints gRPC docs\")\n\n\u003cbr /\u003e\n\nAs described in [Adding CORS support to\nESP](/endpoints/docs/openapi/specify-proxy-startup-options#adding_cors_support_to_esp),\nyou can configure the [Extensible Service Proxy\n(ESP)](/endpoints/docs/openapi/glossary#extensible_service_proxy) to support CORS.\nIf the ESP options don't provide the CORS support that your\napplication requires, you can add the CORS options to ESP's configuration file,\n`nginx.conf`.\n\nAdding the CORS options to `nginx.conf`\n---------------------------------------\n\nTo add the CORS options:\n\n1. Start with a `nginx.conf` file that contains the configuration required by\n Cloud Endpoints. You can start with the [sample\n `nginx.conf`](https://github.com/GoogleCloudPlatform/endpoints-samples/blob/master/k8s/nginx.conf),\n or if you have already deployed ESP, you can SSH to the ESP container and\n copy the `nginx.conf` file from the `/etc/nginx/endpoints/` directory.\n\n2. Add the CORS options that your application requires to `nginx.conf`. You can\n use the [CORS on NGINX](https://enable-cors.org/server_nginx.html) example\n as a starting point.\n\n3. Start ESP with the `--nginx_config` option with the path to the custom\n `nginx.conf` file.\n\nWhat's next\n-----------\n\n- Learn about [ESP's startup options](/endpoints/docs/openapi/specify-proxy-startup-options).\n\n- Learn how to [SSH to ESP's container on GKE](/endpoints/docs/openapi/troubleshoot-gke-deployment#checking_configuration_files).\n\n- Learn about [using a custom nginx.conf on GKE](/endpoints/docs/openapi/custom-nginx)."]]