在混合环境中,您可以创建一个或多个环境,并为每个环境分配一个主机别名。主机别名是 DNS 名称。传入该 DNS 名称的入站流量由 Ingress 路由到该环境。在内部,每个环境都分配给一个且仅一个消息处理器,该处理器负责处理代理请求、应用政策以及路由来往目标服务的流量。因此,主机别名决定了任何给定传入请求的消息处理器。
[[["易于理解","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-21。"],[[["\u003cp\u003eThis documentation version is end-of-life and should be upgraded to a newer version, as outlined in the supported versions documentation.\u003c/p\u003e\n"],["\u003cp\u003eApigee hybrid uses environments to provide isolated sandboxes for API proxies, where each environment is linked to a unique host alias (DNS name) that determines which message processor handles incoming requests.\u003c/p\u003e\n"],["\u003cp\u003eBest practice dictates creating multiple environments and deploying a limited number of proxies to each, rather than deploying all proxies to a single environment, which can cause a plethora of issues.\u003c/p\u003e\n"],["\u003cp\u003eEnvironments can share the same host alias, but this necessitates using base path routing to direct traffic to the appropriate environment based on the proxy's base path.\u003c/p\u003e\n"],["\u003cp\u003eLimiting the number of proxies per environment improves message processor boot-up time, prevents unnecessary scaling of all proxies due to high traffic on one, and minimizes the impact of proxy crashes.\u003c/p\u003e\n"]]],[],null,["# About environments\n\n| You are currently viewing version 1.1 of the Apigee hybrid documentation. **This version is end of life.** You should upgrade to a newer version. For more information, see [Supported versions](/apigee/docs/hybrid/supported-platforms#supported-versions).\n\nAn *environment* provides an isolated context or \"sandbox\" for running API proxies.\nIn a single organization, you can create multiple environments. For more information, see\n[About environments and environment groups](/apigee/docs/api-platform/fundamentals/environments-overview).\n\nDuring a basic installation, you [added an\nenvironment](/apigee/docs/hybrid/v1.1/precog-add-environment) for testing. It's a best practice, however, to create multiple environments\nand to deploy a [limited number of proxies](#limit-the-number-of-proxy-deployments)\nto each one.\n\nAbout virtual hosts and environments\n------------------------------------\n\n\nApigee hybrid uses\n[Istio ingress gateways](https://istio.io/docs/tasks/traffic-management/ingress/ingress-control/)\nto handle incoming API traffic. The MART and\nruntime services are both configured with Istio ingress gateways to manage their\nconnections that are exposed outside the cluster. This\nmeans, for example, that all HTTP and HTTPS requests to an API proxy are first handled\nby an Istio ingress gateway.\n\n\nIn hybrid, you create one or more environments and assign to each environment a *host alias* .\nThe host alias is a DNS name. Incoming traffic to that DNS name is routed by the ingress to that\nenvironment. Internally, each environment is assigned to one and only one [message processor](/apigee/docs/hybrid/v1.1/mp-config),\nwhich does the work of processing proxy requests, applying policies and routing traffic to and\nfrom target services. Therefore, the host alias determines which message processor receives any\ngiven incoming request.\n\n\nThe following code shows an example configuration where multiple environments are\ndefined. (Such configurations belong in your overrides file.) Note that environments\n**dev1** and **prod1** have different host aliases: \n\n```\nenvs:\n - name: dev1\n hostAlias: \"apitest.mydomain.net\"\n ...\n\n - name: prod1\n hostAlias: \"apiprod.mydomain.net\"\n ...\n```\n\n\nSuppose a proxy with the base path `/foo1` is deployed to environment\n**dev1**. You could call the proxy like this: \n\n```\ncurl -k https://apitest.mydomain.net/foo1\n```\n\n\nWhen this call hits the ingress, the ingress knows to send it to the message processor\nassociated with the `dev1` environment, which handles the request.\n\n\nSimilarly, if `foo1` is also deployed to the `prod1` environment,\nyou could make a proxy\nrequest like this, to the host alias `apiprod.mydomain.net`: \n\n```\ncurl -k https://apiprod.mydomain.net/foo1\n```\n\n\nAnd the call is routed by the ingress to the MP associated with that host.\n| **NOTE** On a request to an API proxy, the ingress compares the `Host` header of the incoming request to the list of host aliases to determine which virtual host handles the request. `curl` commands, browsers, and many other utilities automatically set the `Host` header with the domain of the request. If for any reason your app is not setting the `Host` header automatically, you must set it manually.\n\n\nIn summary, each environment that you create must have a host alias assigned to it.\nEach environment maps to one and only one message processor, and the host alias determines\nwhich message processor receives a given request.\n\nEnvironments can share the same host alias\n------------------------------------------\n\n\nApigee hybrid lets you create multiple environments that you can manage however you wish. For\ninstance, you can create several dev environments, **dev1** , **dev2** ,\n**dev3**, and so on, and map a\nsingle host alias to each one. Furthermore, you can deploy multiple proxies to each environment.\n\n\n**Antipattern**: Deploy all of your proxies to one hybrid environment.\n\n\n**Best practice** : Create multiple environments and deploy a limited number of proxies\nto each one. The technique for managing how hybrid routes proxy calls to the correct\nenvironment that share a host alias is called [base path routing](/apigee/docs/hybrid/v1.1/base-path-routing).\n\n\nFor example, in the following configuration, environments **dev1** and\n**dev2** share the same host alias: \n\n```\nenvs:\n - name: dev1\n hostAlias: \"apitest.mydomain.net\"\n ...\n - name: dev2\n hostAlias: \"apitest.mydomain.net\"\n ...\n```\n\n\nWhen multiple environments share the same host alias, you must use\nthe configuration technique called\n*base path routing* to map specific proxy base paths to specific environments. See\n[base path routing](/apigee/docs/hybrid/v1.1/base-path-routing) for more information.\n\nLimit the number of proxy deployments\n-------------------------------------\n\n\nFor hybrid, the fact that many environments can share the same virtual host means\nthat you must think carefully about how you manage your proxy deployments to any given\nenvironment. In hybrid, the best practice is to create multiple environments and deploy\na limited number of proxies to each one.\n\n\n**How many proxies should you deploy to an environment?** There is not a set answer\nto this question; however, the following table provides general guidance on why it's a\ngood idea to limit the number of proxies deployed to each environment and what you\nneed to think about when managing proxy deployments:\n| **NOTE:** When deciding how many proxies to deploy to an environment, be sure to consider the product configuration limits described in [Limits](/apigee/docs/api-platform/reference/limits#hybrid).\n\nEnviroment configuration reference\n----------------------------------\n\n\nFor a complete list of environment configuration elements, see `envs` in the\n[Configuration property reference](/apigee/docs/hybrid/v1.1/config-prop-ref#envs).\n\nWorking with environments\n-------------------------\n\n\nFor more information about configuration, see the following topics:\n\n- [Creating new environments](/apigee/docs/hybrid/v1.1/environment-create)\n- [Deleting environments](/apigee/docs/hybrid/v1.1/environment-delete)\n- [Base path routing](/apigee/docs/hybrid/v1.1/base-path-routing)"]]