> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aviatrix.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuring an AWS Load Balancer with SSL in Front of Aviatrix Controller

> The Aviatrix Controller supports adding an SSL certificate. However, sometimes you may prefer to put an AWS Load Balancer (ALB) in front of the Controller.

The Aviatrix Controller supports adding an SSL certificate. However, sometimes
you may prefer to put an AWS Load Balancer (ALB) in front of the Controller.

![aws ssl lb](https://mintcdn.com/aviatrix-14b37c43/Y73dDPMr0NB7yfrH/images/guides/controlplane/aws-ssl-lb.png?fit=max\&auto=format\&n=Y73dDPMr0NB7yfrH\&q=85\&s=24fb652cdc9f4ff6e8d26e7e1477344f)

Follow these steps to place the Aviatrix Controller behind an AWS ALB:

1. Log into your AWS console.

2. Go to EC2 > Load Balancers in the region where your Aviatrix Controller is
   running.

3. Click **Create load balancer**.

4. Click **Create** under Application Load Balancer.

   ![500](https://mintcdn.com/aviatrix-14b37c43/Y73dDPMr0NB7yfrH/images/guides/controlplane/aws-lb-1.png?fit=max\&auto=format\&n=Y73dDPMr0NB7yfrH\&q=85\&s=ff9b42712ca24c0737fef018d6d06010)

5. On the Create Application Load Balancer page, under Basic configuration,
   enter a name for the load balancer.

6. Also under Basic Configuration, select **Internet-Facing** for the Scheme.

   ![500](https://mintcdn.com/aviatrix-14b37c43/Y73dDPMr0NB7yfrH/images/guides/controlplane/aws-lb-2.png?fit=max\&auto=format\&n=Y73dDPMr0NB7yfrH\&q=85\&s=f2f5b7abe00c6d93c12c100e54375858)

7. Under Network mapping, select at least two Availability Zones and one subnet
   per zone.

8. Under Security groups, select the appropriate security group from the
   Security groups drop-down. This security group should allow traffic on port
   443 from your desired source network(s). A default security group may already
   be selected.

   ![500](https://mintcdn.com/aviatrix-14b37c43/Y73dDPMr0NB7yfrH/images/guides/controlplane/aws-lb-3.png?fit=max\&auto=format\&n=Y73dDPMr0NB7yfrH\&q=85\&s=bfb57fd2953521433c041afea3789c36)

9. Under Listeners and routing, select **HTTPS** from the Protocol list.

10. Select a target group from the Default action field.

11. (optional) If needed, click **Create target group** under the **Default
    action** field. This opens the EC2 > Target groups > Create target group
    Console page in a new web browser tab.

    ![500](https://mintcdn.com/aviatrix-14b37c43/Y73dDPMr0NB7yfrH/images/guides/controlplane/aws-lb-3a.png?fit=max\&auto=format\&n=Y73dDPMr0NB7yfrH\&q=85\&s=7ab6e113d0588afd7b7eb06cf2ebe585)

    On the Specify group details page:

    1. Select the **Instances** target type.
    2. Enter a target group name.
    3. Select the HTTPS Protocol and port 443.
    4. Select the VPC where the Controller resides (normally named
       aviatrix-mgt-vpc).
    5. Under Health checks, select the HTTPS Protocol and the default Path of
       '/'.
    6. Click **Next** to register the target group.

12. On the Create Application Load Balancer page, under Secure listener
    settings, select **From ACM** from the Default SSL/TLS Certificate drop-down
    and select your certificate. If necessary you can
    [request a new certificate](https://docs.aws.amazon.com/acm/latest/userguide/gs-acm-request-public.html).

    ![500](https://mintcdn.com/aviatrix-14b37c43/Y73dDPMr0NB7yfrH/images/guides/controlplane/aws-lb-5.png?fit=max\&auto=format\&n=Y73dDPMr0NB7yfrH\&q=85\&s=7fd8b0029fd4f246f96d8392d4a6b742)

13. Review and create the load balancer.

14. Collect the DNS name from the load balancer.

    ![500](https://mintcdn.com/aviatrix-14b37c43/Y73dDPMr0NB7yfrH/images/guides/controlplane/aws-lb-6.png?fit=max\&auto=format\&n=Y73dDPMr0NB7yfrH\&q=85\&s=d95a33eab3dc60c3a80afe783009b0b7)

15. Create a DNS CNAME record that points your desired name to the load
    balancer's DNS name.

    > [!NOTE]
    >
    > The DNS CNAME record must match the name used in the SSL certificate or
    > you will receive a warning.

16. Ensure that your Controller security groups have an inbound allow policy for
    port 443 for the VPC CIDR, so that the load balancer can talk to the
    Controller.

> [!NOTE]
>
> If you have enabled HA for your Aviatrix Controller, you can point your auto
> scaling group to the target group of your load balancer in the event of a
> failover. The Max value should always be 1. Having more than one active
> Controller for any given set of services is not supported if deployed behind a
> load balancer.

## Restricting Access to Only the SAML Endpoint

If you place this ALB in front of the Controller specifically to expose the

[SAML authentication](https://docs.aviatrix.com/docs/enterprise/10.1/guides/uservpn/user-vpn-saml-authentication.md)
endpoint for SSO login, you can use a path-based listener rule to forward only
SAML traffic to the Controller and send everything else to a dummy target group.
This keeps the Controller's administrative interface closed to the internet
while still letting users reach the SAML login flow through the ALB.

1. In EC2 > Target Groups, create a second target group that does not point to a
   valid Controller listener (for example, assign it an unused port). Do not
   register the Controller instance with this target group; it exists only to
   absorb traffic you want to block.

2. On the ALB's HTTPS listener, add a new rule above the default action:

   1. For **IF**, select **Path** and enter `/flask/*`.
   2. For **THEN**, select **Forward to** and select the target group that
      points to the Controller.

3. Set the listener's default rule (no matching conditions) to forward to the
   dummy target group you created in step 1.

With this rule in place, only requests to the SAML endpoint (for example,
`/flask/saml/sso/[SP Name]`) reach the Controller through the ALB. Requests to
any other path are sent to the dummy target group and dropped.

> [!NOTE]
>
> If you already configured SAML before placing the Controller behind this ALB,
> log into the Controller through the ALB's certificate domain name after
> completing this configuration. This regenerates the SAML-related URLs (IdP
> URLs and VPN user certificates) against the new domain name. Update the
> Assertion Consumer Service URL at your IdP to match the ALB's domain name, and
> download the VPN user certificate again. Confirm that the domain name under
> the AviatrixController section is correct, and update it if it is not.

> [!WARNING]
>
> Gateways communicate with the Controller directly and do not route through
> this ALB. Ensure the Controller's own security group for port 443 allows both
> the load balancer's internal IP address (usually the VPC CIDR) and the public
> IP address of each gateway that needs to reach the Controller. Restricting the
> Controller's security group to only the load balancer blocks
> gateway-to-Controller communication.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.