Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
建立自訂 nginx.conf 來支援 CORS
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
如新增 CORS 支援至 ESP 所述,您可以將可擴充服務 Proxy (ESP) 設定為支援 CORS。如果 ESP 選項並未提供應用程式需要的 CORS 支援,您可以將 CORS 選項新增至 ESP 的設定檔 nginx.conf。
將 CORS 選項新增至 nginx.conf
如要新增 CORS 選項,請執行下列操作:
先處理 nginx.conf 檔案且該檔案包含 Cloud Endpoints 需要的設定。您可以從範例nginx.conf開始,或在部署 ESP 後,透過 SSH 連線至 ESP 容器,然後從 /etc/nginx/endpoints/ 目錄複製 nginx.conf 檔案。
將應用程式需要的 CORS 選項新增至 nginx.conf。一開始,您可以使用 NGINX 中的 CORS 範例。
使用 --nginx_config 選項啟動 ESP,且該選項中包含自訂 nginx.conf 檔案的路徑。
後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2026-05-19 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2026-05-19 (世界標準時間)。"],[],[]]