专用出口 IP 地址

了解如何设置和使用专用出口IP地址,该地址允许来自AEM的出站连接源自专用IP。

专用出口IP地址是什么?

专用出口IP地址允许来自AEM as a Cloud Service的请求使用专用IP地址,允许外部服务按此IP地址过滤传入请求。 与灵活出口端口一样,专用出口IP允许您在非标准端口上出口。

Cloud Manager程序只能具有​ 单个 ​网络基础架构类型。 在执行以下命令之前,请确保专用出口IP地址是AEM as a Cloud Service最适合的网络基础架构类型

先决条件

使用Cloud Manager API设置专用出口IP地址时,需要满足以下条件:

有关更多详细信息,请观看以下演练,了解如何设置、配置和获取Cloud Manger API凭据,以及如何使用它们进行Cloud Manager API调用。

本教程使用curl来进行Cloud Manager API配置。 提供的curl命令采用Linux/macOS语法。 如果使用Windows命令提示符,请将\换行符替换为^

在程序上启用专用出口IP地址

首先,在AEM as a Cloud Service上启用并配置专用出口IP地址。

Cloud Manager

可使用Cloud Manager启用专用出口IP地址。 以下步骤概述了如何使用Cloud Manager在AEM as a Cloud Service上启用专用出口IP地址。

  1. 以Cloud Manager业务负责人身份登录到Adobe Experience Manager Cloud Manager

  2. 导航到所需的项目。

  3. 在左侧菜单中,导航到​ 服务>网络基础架构

  4. 选择​ 添加网络基础架构 ​按钮。

    添加网络基础架构

  5. 在​ 添加网络基础架构 ​对话框中,选择​ 专用出口IP地址 ​选项,然后选择​ 区域 ​以创建专用出口IP地址。

    添加专用出口IP地址

  6. 选择​ 保存 ​以确认添加专用出口IP地址。

    确认专用出口IP地址创建

  7. 等待创建网络基础结构并标记为​ 就绪。 此过程最多可能需要1小时。

    专用出口IP地址创建状态

在创建专用出口IP地址后,您现在可以使用Cloud Manager API对其进行配置,如下所述。

Cloud Manager API

可以使用Cloud Manager API启用专用出口IP地址。 以下步骤概述了如何使用Cloud Manager API在AEM as a Cloud Service上启用专用出口IP地址。

  1. 首先,使用Cloud Manager API listRegions操作确定需要高级联网的区域。 进行后续Cloud Manager API调用需要region name。 通常,会使用生产环境所在的区域。

    环境的详细信息下的Cloud Manager中查找您的AEM as a Cloud Service环境所在的地区。 Cloud Manager中显示的地区名称可以是映射到Cloud Manager API中使用的地区代码

    listRegions HTTP请求

    code language-shell
    $ curl -X GET https://cloudmanager.adobe.io/api/program/{programId}/regions \
        -H 'x-gw-ims-org-id: <ORGANIZATION_ID>' \
        -H 'x-api-key: <CLIENT_ID>' \
        -H 'Authorization: Bearer <ACCESS_TOKEN>' \
        -H 'Content-Type: application/json'
    
  2. 使用Cloud Manager API createNetworkInfrastructure操作为Cloud Manager程序启用专用出口IP地址。 使用从Cloud Manager API listRegions操作获得的相应region代码。

    createNetworkInfrastructure HTTP请求

    code language-shell
    $ curl -X POST https://cloudmanager.adobe.io/api/program/{programId}/networkInfrastructures \
        -H 'x-gw-ims-org-id: <ORGANIZATION_ID>' \
        -H 'x-api-key: <CLIENT_ID>' \
        -H 'Authorization: Bearer <ACCESS_TOKEN>' \
        -H 'Content-Type: application/json' \
        -d '{ "kind": "dedicatedEgressIp", "region": "va7" }'
    

    等待15分钟,让Cloud Manager计划配置网络基础设施。

  3. 检查程序是否已使用Cloud Manager API getNetworkInfrastructure操作,使用上一步中从createNetworkInfrastructure HTTP请求返回的id,完成​ 专用出口IP地址 ​配置。

    getNetworkInfrastructure HTTP请求

    code language-shell
    $ curl -X GET https://cloudmanager.adobe.io/api/program/{programId}/networkInfrastructure/{networkInfrastructureId} \
        -H 'x-gw-ims-org-id: <ORGANIZATION_ID>' \
        -H 'x-api-key: <CLIENT_ID>' \
        -H 'Authorization: Bearer <ACCESS_TOKEN>' \
        -H 'Content-Type: application/json'
    

    验证HTTP响应是否包含​ 就绪 ​的​ 状态。 如果尚未准备就绪,请每隔几分钟重新检查一次状态。

在创建专用出口IP地址后,您现在可以使用Cloud Manager API对其进行配置,如下所述。

为每个环境配置专用出口IP地址代理

  1. 使用enableEnvironmentAdvancedNetworkingConfiguration操作在每个AEM as a Cloud ServiceCloud Manager环境中配置​ 专用出口IP地址 ​配置。

    enableEnvironmentAdvancedNetworkingConfiguration HTTP请求

    code language-shell
    $ curl -X PUT https://cloudmanager.adobe.io/api/program/{programId}/environment/{environmentId}/advancedNetworking \
        -H 'x-gw-ims-org-id: <ORGANIZATION_ID>' \
        -H 'x-api-key: <CLIENT_ID>' \
        -H 'Authorization: Bearer <ACCESS_TOKEN>' \
        -H 'Content-Type: application/json' \
        -d @./dedicated-egress-ip-address.json
    

    dedicated-egress-ip-address.json中定义JSON参数,并通过... -d @./dedicated-egress-ip-address.json提供给curl。

    下载示例dedicated-egress-ip-address.json。 此文件只是一个示例。 根据enableEnvironmentAdvancedNetworkingConfiguration中记录的可选/必填字段根据需要配置文件。

    code language-json
    {
        "nonProxyHosts": [
            "example.net",
            "*.example.org",
        ],
        "portForwards": [
            {
                "name": "mysql.example.com",
                "portDest": 3306,
                "portOrig": 30001
            },
            {
                "name": "smtp.sendgrid.net",
                "portDest": 465,
                "portOrig": 30002
            }
        ]
    }
    

    专用出口IP地址配置的HTTP签名仅与灵活出口端口不同,因为它也支持可选的nonProxyHosts配置。

    nonProxyHosts声明了一组主机,端口80或443应通过默认共享IP地址范围而不是专用出口IP进行路由。 nonProxyHosts可能很有用,因为Adobe会自动优化通过共享IP传出的流量。

    对于每个portForwards映射,高级联网定义以下转发规则:

    table 0-row-5 1-row-5
    代理主机 代理端口 外部主机 外部端口
    AEM_PROXY_HOST portForwards.portOrig portForwards.name portForwards.portDest
  2. 对于每个环境,使用Cloud Manager API getEnvironmentAdvancedNetworkingConfiguration操作验证出口规则是否有效。

    getEnvironmentAdvancedNetworkingConfiguration HTTP请求

    code language-shell
    $ curl -X GET https://cloudmanager.adobe.io/api/program/{programId}/environment/{environmentId}/advancedNetworking \
        -H 'x-gw-ims-org-id: <ORGANIZATION_ID>' \
        -H 'x-api-key: <CLIENT_ID>' \
        -H 'Authorization: <YOUR_TOKEN>' \
        -H 'Content-Type: application/json'
    
  3. 可以使用Cloud Manager API enableEnvironmentAdvancedNetworkingConfiguration操作更新专用出口IP地址配置。 请记住enableEnvironmentAdvancedNetworkingConfigurationPUT操作,因此必须随每次调用此操作提供所有规则。

  4. 在主机p{programId}.external.adobeaemcloud.com上使用DNS解析器(如DNSChecker.org)或通过从命令行运行dig获取​ 专用出口IP地址

    code language-shell
    $ dig +short p{programId}.external.adobeaemcloud.com
    

    主机名不能为pinged,因为它是出口,不是 ​和入口。

    请注意,专用出口IP地址由程序中的所有AEM as a Cloud Service环境共享。

  5. 现在,您可以在自定义AEM代码和配置中使用专用出口IP地址。 在使用专用出口IP地址时,AEM as a Cloud Service连接到的外部服务通常配置为仅允许来自此专用IP地址的流量。

通过专用出口IP地址连接到外部服务

在启用了专用出口IP地址的情况下,AEM代码和配置可以使用专用出口IP调用外部服务。 AEM对两种外部调用的处理方式有所不同:

  1. 对外部服务的HTTP/HTTPS调用
    • 包括对在标准80或443端口以外的端口上运行的服务发出的HTTP/HTTPS调用。
  2. 对外部服务的非HTTP/HTTPS调用
    • 包括任何非HTTP调用,例如与Mail服务器、SQL数据库或在其他非HTTP/HTTPS协议上运行的服务的连接。

默认情况下,允许标准端口(80/443)上来自AEM的HTTP/HTTPS请求,但如果未按照以下所述进行适当配置,则这些请求不使用专用出口IP地址。

TIP
有关完整的路由规则集,请参阅AEM as a Cloud Service的专用出口IP地址文档。

HTTP/HTTPS

从AEM创建HTTP/HTTPS连接时,如果使用专用出口IP地址,则会使用专用出口IP地址自动代理出AEM。 无需其他代码或配置即可支持HTTP/HTTPS连接。

代码示例

HTTP/HTTPS

HTTP/HTTPS

Java™代码示例使用HTTP/HTTPS协议从AEM as a Cloud Service建立与外部服务的HTTP/HTTPS连接。

与外部服务的非HTTP/HTTPS连接

创建非HTTP/HTTPS连接时(例如 AEM SQL、SMTP等),必须通过AEM提供的特殊主机名建立连接。

变量名称
使用
Java™代码
OSGi配置
AEM_PROXY_HOST
非HTTP/HTTPS连接的代理主机
System.getenv("AEM_PROXY_HOST")
$[env:AEM_PROXY_HOST]

然后,通过AEM_PROXY_HOST和映射端口(portForwards.portOrig)调用与外部服务的连接,AEM随后将其路由到映射的外部主机名(portForwards.name)和端口(portForwards.portDest)。

代理主机
代理端口
外部主机
外部端口
AEM_PROXY_HOST
portForwards.portOrig
portForwards.name
portForwards.portDest

代码示例

使用JDBC DataSourcePool的SQL连接

使用JDBC DataSourcePool的 SQL连接

通过配置AEM的JDBC数据源池连接到外部SQL数据库的Java™代码示例。

使用Java API的SQL连接

使用Java™ API的 SQL连接

Java™代码示例使用Java™的SQL API连接到外部SQL数据库。

虚拟专用网络 (VPN)

电子邮件服务

使用AEM连接到外部电子邮件服务的OSGi配置示例。

recommendation-more-help
4859a77c-7971-4ac9-8f5c-4260823c6f69