Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
创建自定义 nginx.conf 以支持 CORS
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
您可以将 Extensible Service Proxy (ESP) 配置为支持 CORS(请参阅向 ESP 添加 CORS 支持)。如果 ESP 选项未提供应用所需的 CORS 支持,您可以将 CORS 选项添加到 ESP 的配置文件 nginx.conf 中。
将 CORS 选项添加到 nginx.conf
要添加 CORS 选项,请执行以下操作:
首先找到包含 Cloud Endpoints 所需配置的 nginx.conf 文件。您可以从示例 nginx.conf 入手;如果您已经部署了 ESP,则可以通过 SSH 连接到 ESP 容器,然后从 /etc/nginx/endpoints/ 目录中复制 nginx.conf 文件。
将应用所需的 CORS 选项添加到 nginx.conf。您可从在 NGINX 上使用 CORS 示例入手。
使用 --nginx_config 选项启动 ESP,其中的路径设置为指向自定义 nginx.conf 文件。
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2026-05-09。
[[["易于理解","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):2026-05-09。"],[],[]]