设置服务账号凭据 JSON 文件。如果提供此选项,ESP 将使用服务账号生成用于调用 Service Infrastructure API 的访问令牌。
仅当 ESP 在 Google Cloud以外的平台(例如本地桌面设备、Kubernetes 或其他云服务商平台)上运行时,您才需要指定此选项。如需了解详情,请参阅 创建服务账号。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-18。"],[[["\u003cp\u003eThe Extensible Service Proxy (ESP) is an NGINX-based proxy used with Cloud Endpoints for API management, configured via startup options when launching its Docker container.\u003c/p\u003e\n"],["\u003cp\u003eESP startup options, like \u003ccode\u003e--service\u003c/code\u003e, \u003ccode\u003e--rollout_strategy\u003c/code\u003e, and \u003ccode\u003e--backend\u003c/code\u003e, are specified in the \u003ccode\u003edocker run\u003c/code\u003e command or the Kubernetes deployment manifest's \u003ccode\u003eargs\u003c/code\u003e field, defining the behavior of the proxy.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003e--rollout_strategy=managed\u003c/code\u003e option is recommended as it allows ESP to automatically use the latest deployed service configuration without requiring a specific configuration ID.\u003c/p\u003e\n"],["\u003cp\u003eCORS support can be enabled in ESP using \u003ccode\u003e--cors_preset=basic\u003c/code\u003e or \u003ccode\u003e--cors_preset=cors_with_regex\u003c/code\u003e, allowing for configuration of \u003ccode\u003eAccess-Control-Allow-Origin\u003c/code\u003e and other related headers, and you can also use a custom \u003ccode\u003enginx.conf\u003c/code\u003e file to meet your applications needs.\u003c/p\u003e\n"],["\u003cp\u003eESP offers options for setting various ports (HTTP/1.x, HTTP/2, HTTPS), specifying backend server addresses, managing status ports, custom NGINX configurations, and integrating service account credentials for non-Google Cloud platforms.\u003c/p\u003e\n"]]],[],null,["# Extensible Service Proxy startup options\n\n[OpenAPI](/endpoints/docs/openapi/specify-proxy-startup-options \"View this page for the Cloud Endpoints OpenAPI docs\") \\| gRPC\n\n\u003cbr /\u003e\n\nThe [Extensible Service Proxy\n(ESP)](/endpoints/docs/grpc/glossary#extensible_service_proxy) is an\n[NGINX-based](/endpoints/docs/grpc/glossary#nginx) proxy that enables\nCloud Endpoints to provide API management features. You configure\nESP by specifying options when you start the ESP\nDocker container. When the ESP container starts, it runs a script\ncalled `start_esp`, which writes the NGINX configuration file by using the\noptions that you specified and launches ESP.\n\nYou specify ESP startup options in the `docker run` command, for example: \n\n```\nsudo docker run \\\n --detach \\\n DOCKER_ARGUMENTS \\\n gcr.io/endpoints-release/endpoints-runtime:1 \\\n --service=SERVICE_NAME \\\n --rollout_strategy=managed \\\n --backend=YOUR_API_CONTAINER_NAME:8080\n```\n\nIf you are deploying ESP to Kubernetes, you specify the startup\noptions in your deployment manifest file in the `args` field, for example: \n\n```\ncontainers:\n- name: esp\n image: gcr.io/endpoints-release/endpoints-runtime:1\n args: [\n \"--http_port=8081\",\n \"--backend=127.0.0.1:8080\",\n \"--service=SERVICE_NAME\",\n \"--rollout_strategy=managed\"\n ]\n```\n\nThe following table describes ESP's startup options.\n\n^1^ These ports are optional and must be distinct from each other.\nIf you don't specify any port option, ESP accepts HTTP/1.x\nconnections on port `8080`.\nFor HTTPS connections, ESP expects the TLS secrets to be\nlocated at `/etc/nginx/ssl/nginx.crt` and `/etc/nginx/ssl/nginx.key`.\n\nSample command-line invocations\n-------------------------------\n\nThe following examples show how to use some of the command-line arguments:\n\nTo start ESP to handle requests coming in at HTTP/1.x port `80`\nand HTTPS port `443` and send the requests to your API backend at\n`127.0.0.1:8000`: \n\n```\nsudo docker run \\\n --detach \\\n DOCKER_ARGUMENTS \\\n gcr.io/endpoints-release/endpoints-runtime:1\n --service=echo-api.endpoints.example-project-12345.cloud.goog \\\n --rollout_strategy=managed \\\n --http_port=80 \\\n --ssl_port=443 \\\n --backend=127.0.0.1:8000\n```\n\nTo start ESP with a custom NGINX configuration by using the\nservice account credentials file to fetch the service config and connect to the\nservice control: \n\n```\nsudo docker run \\\n --detach \\\n --volume=$HOME/Downloads:/esp \\\n DOCKER_ARGUMENTS \\\n gcr.io/endpoints-release/endpoints-runtime:1 \\\n --service=echo-api.endpoints.example-project-12345.cloud.goog \\\n --rollout_strategy=managed \\\n --service_account_key=/esp/serviceaccount.json \\\n --nginx_config=/esp/nginx.conf\n \n```\n\nNote that you must use the Docker flags `--volume` or `--mount` to mount the\nJSON file containing the private key for the service account and the custom\nNGINX config file as volumes inside ESP's Docker container. The\npreceding example maps the `$HOME/Downloads` directory on the local computer to\nthe `esp` directory in the container. When you save the private key file for the\nservice account, it is typically downloaded to the `Downloads` directory. You\ncan copy the private key file to another directory if you want to. See\n[Manage data in Docker](https://docs.docker.com/storage/)\nfor more information.\n\nAdding CORS support to ESP\n--------------------------\n\nPlease refer to [Support CORS](/endpoints/docs/openapi/support-cors) for a description of available CORS support options. This section describes using ESP startup flags to support CORS.\n\nTo enable CORS support in ESP, include the `--cors_preset` option\nand set it to either `basic` or `cors_with_regex`. When you include\n`--cors_preset=basic` or `--cors_preset=cors_with_regex`, ESP:\n\n- Assumes all location paths have the same CORS policy.\n- Responds to both [simple requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#simple_requests) and [preflight](https://developer.mozilla.org/docs/Web/HTTP/CORS#Preflighted_requests) `HTTP OPTIONS` requests.\n- Caches the result of the preflight `OPTIONS` request for up to 20 days (1728000 seconds).\n- Sets the response headers to the following values:\n\n ```scdoc\n Access-Control-Allow-Origin: *\n Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS\n Access-Control-Allow-Headers: DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization\n Access-Control-Expose-Headers: Content-Length,Content-Range\n ```\n\nTo override the default value of\n[`Access-Control-Allow-Origin`](https://developer.mozilla.org/docs/Web/HTTP/Headers/Access-Control-Allow-Origin),\nspecify one of the following options:\n\nAfter setting `--cors_preset=basic` or `--cors_preset=cors_with_regex` to enable\nCORS, you can override the default values of the other response headers by\nspecifying one or more of the following options:\n\nIf the ESP CORS startup options don't suit the needs of your\napplication, you can create a custom `nginx.conf` file with the CORS support\nthat your application requires. For more information, see\n[Creating a custom `nginx.conf` to support CORS](/endpoints/docs/grpc/custom-cors-nginx).\n\nWhat's next\n-----------\n\nLearn about:\n\n- [Deploying ESP and your API backend to Google Cloud](/endpoints/docs/grpc/deploy-api-backend)\n- [Running ESP locally or on another platform](/endpoints/docs/grpc/running-esp-localdev)\n- The [`start_esp`](https://github.com/cloudendpoints/esp/tree/master/start_esp) script on GitHub"]]