HTTP/HTTPS connections for dedicated egress IP address and VPN

HTTP/HTTPS connections are automatically proxied out of AEM as a Cloud Service with dedicated egress IP address or VPN, and they do not need any special portForwards rules.

Advanced networking support

The following code example is supported by the following advanced networking options.

Ensure the the dedicated egress IP address or VPN advanced networking configuration has been set up prior to following this tutorial.

This code example is only for Dedicated Egress IP address and VPN. A similar, but different code example is available for HTTP/HTTPS connections on non-standard ports for Flexible Port Egress.

Code example

This Java™ code example is of an OSGi service that can run in AEM as a Cloud Service that makes an HTTP connection to an external web server on 8080. The HTTPS (or HTTP) connections are automatically proxied out of AEM as a Cloud Service, and do not require special development.

It is recommended the Java™ 11 HTTP APIs are used to make HTTP/HTTPS calls from AEM.
  • core/src/com/adobe/aem/wknd/examples/connections/impl/
package com.adobe.aem.wknd.examples.core.connections.impl;

import com.adobe.aem.wknd.examples.core.connections.ExternalService;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.time.Duration;

public class HttpExternalServiceImpl implements ExternalService {
    private static final Logger log = LoggerFactory.getLogger(HttpExternalServiceImpl.class);

    // client with connection pool reused for all requests
    private HttpClient client = HttpClient.newBuilder().build();

    public boolean isAccessible() {

        // Prepare the full URI to request, note this will have the
        // - Scheme (http/https)
        // - External host name
        // - External port
        // The external service URI, including the scheme/host/port, is defined in code, rather than in Cloud Manager portForwards rules.
        URI uri = URI.create("");

        // Prepare the HttpRequest
        HttpRequest request = HttpRequest.newBuilder().uri(uri).timeout(Duration.ofSeconds(2)).build();

        // Send the HttpRequest using the configured HttpClient
        HttpResponse<String> response = null;
        try {
            // Request the URL
            response = client.send(request, HttpResponse.BodyHandlers.ofString());

            log.debug("HTTP response body: {} ", response.body());

            // Our simple example returns true is response is successful! (200 status code)
            return response.statusCode() == 200;
        } catch (IOException e) {
            return false;
        } catch (InterruptedException e) {
            return false;