Ajouter ou supprimer des listeners

Vous pouvez ajouter un ou plusieurs listeners à un load balancer et les supprimer à tout moment si vous n’en avez plus besoin. Ajouter un listener à un load balancer lui permet d’écouter des flux entrants sur un port et dans un protocole que vous spécifiez, et d’envoyer la charge réseau vers les machines virtuelles (VM) backend en utilisant un port et un protocole que vous spécifiez également.

Vous pouvez configurer uniquement un type de health checks par load balancer en spécifiant le port et le protocole des VM backend à vérifier. Nous vous recommandons donc de créer un load balancer par service pour éviter qu’une panne ne soit pas détectée, vos listeners devant donc envoyer la charge réseau vers les VM backend en utilisant le même port et le même protocole.

Vous ne pouvez pas modifier un listener existant. La seule façon de modifier le port et le protocole utilisé du côté du load balancer ou du côté des VM backend est d’ajouter un listener avec la configuration appropriée, et de supprimer le précédent si besoin.

Ajouter des listeners avec Cockpit v2

Ajouter ou supprimer des listeners avec OSC CLI

Ajouter un listener à un load balancer

À ce jour, cette section est disponible en anglais uniquement.

The CreateLoadBalancerListeners command creates one or more listeners for a specified load balancer.

For more information, see About Load Balancers.

Request sample
$ osc-cli api CreateLoadBalancerListeners --profile "default" \
    --LoadBalancerName "example-lbu" \
    --Listeners '[
        {
          "BackendPort": 58,
          "BackendProtocol": "TCP",
          "LoadBalancerPort": 62,
          "LoadBalancerProtocol": "TCP",
        },
      ]'

This command contains the following attributes that you need to specify:

  • DryRun: (optional) If true, checks whether you have the required permissions to perform the action.

  • Listeners: One or more listeners for the load balancer.

    • BackendPort: (optional) The port on which the backend VM is listening (between 1 and 65535, both included).

    • BackendProtocol: (optional) The protocol for routing traffic to backend VMs (HTTP | HTTPS | TCP | SSL).

    • LoadBalancerPort: (optional) The port on which the load balancer is listening (between 1 and 65535, both included).

    • LoadBalancerProtocol: (optional) The routing protocol (HTTP | HTTPS | TCP | SSL).

    • ServerCertificateId: (optional) The OUTSCALE Resource Name (ORN) of the server certificate. For more information, see Resource Identifiers > OUTSCALE Resource Names (ORNs).

  • LoadBalancerName: The name of the load balancer for which you want to create listeners.

The CreateLoadBalancerListeners command returns the following elements:

  • LoadBalancer: Information about the load balancer.

    • AccessLog: Information about access logs.

      • IsEnabled: If true, access logs are enabled for your load balancer. If false, they are not. If you set this to true in your request, the OsuBucketName parameter is required.

      • OsuBucketName: The name of the OOS bucket for the access logs.

      • OsuBucketPrefix: The path to the folder of the access logs in your OOS bucket (by default, the root level of your bucket).

      • PublicationInterval: The time interval for the publication of access logs in the OOS bucket, in minutes. This value can be either 5 or 60 (by default, 60).

    • ApplicationStickyCookiePolicies: The stickiness policies defined for the load balancer.

      • CookieName: The name of the application cookie used for stickiness.

      • PolicyName: The mnemonic name for the policy being created. The name must be unique within a set of policies for this load balancer.

    • BackendIps: One or more public IPs of backend VMs.

    • BackendVmIds: One or more IDs of backend VMs for the load balancer.

    • DnsName: The DNS name of the load balancer.

    • HealthCheck: Information about the health check configuration.

      • CheckInterval: The number of seconds between two requests (between 5 and 600 both included).

      • HealthyThreshold: The number of consecutive successful requests before considering the VM as healthy (between 2 and 10 both included).

      • Path: If you use the HTTP or HTTPS protocols, the request URL path.

      • Port: The port number (between 1 and 65535, both included).

      • Protocol: The protocol for the URL of the VM (HTTP | HTTPS | TCP | SSL).

      • Timeout: The maximum waiting time for a response before considering the VM as unhealthy, in seconds (between 2 and 60 both included).

      • UnhealthyThreshold: The number of consecutive failed requests before considering the VM as unhealthy (between 2 and 10 both included).

    • Listeners: The listeners for the load balancer.

      • BackendPort: The port on which the backend VM is listening (between 1 and 65535, both included).

      • BackendProtocol: The protocol for routing traffic to backend VMs (HTTP | HTTPS | TCP | SSL).

      • LoadBalancerPort: The port on which the load balancer is listening (between 1 and 65535, both included).

      • LoadBalancerProtocol: The routing protocol (HTTP | HTTPS | TCP | SSL).

      • PolicyNames: The names of the policies. If there are no policies enabled, the list is empty.

      • ServerCertificateId: The OUTSCALE Resource Name (ORN) of the server certificate. For more information, see Resource Identifiers > OUTSCALE Resource Names (ORNs).

    • LoadBalancerName: The name of the load balancer.

    • LoadBalancerStickyCookiePolicies: The policies defined for the load balancer.

      • CookieExpirationPeriod: The time period, in seconds, after which the cookie should be considered stale.
        If 1, the stickiness session lasts for the duration of the browser session.

      • PolicyName: The name of the stickiness policy.

    • LoadBalancerType: The type of load balancer. Valid only for load balancers in a Net.
      If LoadBalancerType is internet-facing, the load balancer has a public DNS name that resolves to a public IP.
      If LoadBalancerType is internal, the load balancer has a public DNS name that resolves to a private IP.

    • NetId: The ID of the Net for the load balancer.

    • PublicIp: (internet-facing only) The public IP associated with the load balancer.

    • SecuredCookies: Whether secure cookies are enabled for the load balancer.

    • SecurityGroups: One or more IDs of security groups for the load balancers. Valid only for load balancers in a Net.

    • SourceSecurityGroup: Information about the source security group of the load balancer, which you can use as part of your inbound rules for your registered VMs.
      To only allow traffic from load balancers, add a security group rule that specifies this source security group as the inbound source.

      • SecurityGroupAccountId: The account ID of the owner of the security group.

      • SecurityGroupName: The name of the security group.

    • Subnets: The ID of the Subnet in which the load balancer was created.

    • SubregionNames: The ID of the Subregion in which the load balancer was created.

    • Tags: One or more tags associated with the load balancer.

      • Key: The key of the tag, with a minimum of 1 character.

      • Value: The value of the tag, between 0 and 255 characters.

  • ResponseContext: Information about the context of the response.

    • RequestId: The ID of the request.

Result sample
{
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  },
  "LoadBalancer": {
    "Tags": [],
    "SourceSecurityGroup": {
      "SecurityGroupName": "security-group-example",
      "SecurityGroupAccountId": "123456789012"
    },
    "SecuredCookies": false,
    "Subnets": [
      "subnet-12345678"
    ],
    "NetId": "vpc-12345678",
    "BackendVmIds": [],
    "ApplicationStickyCookiePolicies": [],
    "SecurityGroups": [
      "sg-12345678"
    ],
    "LoadBalancerType": "internal",
    "AccessLog": {
      "PublicationInterval": 60,
      "IsEnabled": false
    },
    "DnsName": "internal-example-lbu.123456789.eu-west-2.lbu.outscale.com",
    "HealthCheck": {
      "UnhealthyThreshold": 2,
      "Timeout": 5,
      "CheckInterval": 30,
      "Protocol": "TCP",
      "HealthyThreshold": 10,
      "Port": 80
    },
    "LoadBalancerStickyCookiePolicies": [],
    "SubregionNames": [
      "eu-west-2a"
    ],
    "Listeners": [
      {
        "BackendPort": 58,
        "BackendProtocol": "TCP",
        "LoadBalancerPort": 62,
        "LoadBalancerProtocol": "TCP"
      },
      {
        "BackendPort": 80,
        "BackendProtocol": "TCP",
        "LoadBalancerPort": 80,
        "LoadBalancerProtocol": "TCP"
      }
    ],
    "LoadBalancerName": "example-lbu"
  }
}

Supprimer un listener d’un load balancer

À ce jour, cette section est disponible en anglais uniquement.

The DeleteLoadBalancerListeners command deletes listeners of a specified load balancer.

Request sample
$ osc-cli api DeleteLoadBalancerListeners --profile "default" \
    --LoadBalancerName "example-lbu" \
    --LoadBalancerPorts '[80]'

This command contains the following attributes that you need to specify:

  • DryRun: (optional) If true, checks whether you have the required permissions to perform the action.

  • LoadBalancerName: The name of the load balancer for which you want to delete listeners.

  • LoadBalancerPorts: One or more port numbers of the listeners you want to delete.

The DeleteLoadBalancerListeners command returns the following elements:

  • LoadBalancer: Information about the load balancer.

    • AccessLog: Information about access logs.

      • IsEnabled: If true, access logs are enabled for your load balancer. If false, they are not. If you set this to true in your request, the OsuBucketName parameter is required.

      • OsuBucketName: The name of the OOS bucket for the access logs.

      • OsuBucketPrefix: The path to the folder of the access logs in your OOS bucket (by default, the root level of your bucket).

      • PublicationInterval: The time interval for the publication of access logs in the OOS bucket, in minutes. This value can be either 5 or 60 (by default, 60).

    • ApplicationStickyCookiePolicies: The stickiness policies defined for the load balancer.

      • CookieName: The name of the application cookie used for stickiness.

      • PolicyName: The mnemonic name for the policy being created. The name must be unique within a set of policies for this load balancer.

    • BackendIps: One or more public IPs of backend VMs.

    • BackendVmIds: One or more IDs of backend VMs for the load balancer.

    • DnsName: The DNS name of the load balancer.

    • HealthCheck: Information about the health check configuration.

      • CheckInterval: The number of seconds between two requests (between 5 and 600 both included).

      • HealthyThreshold: The number of consecutive successful requests before considering the VM as healthy (between 2 and 10 both included).

      • Path: If you use the HTTP or HTTPS protocols, the request URL path.

      • Port: The port number (between 1 and 65535, both included).

      • Protocol: The protocol for the URL of the VM (HTTP | HTTPS | TCP | SSL).

      • Timeout: The maximum waiting time for a response before considering the VM as unhealthy, in seconds (between 2 and 60 both included).

      • UnhealthyThreshold: The number of consecutive failed requests before considering the VM as unhealthy (between 2 and 10 both included).

    • Listeners: The listeners for the load balancer.

      • BackendPort: The port on which the backend VM is listening (between 1 and 65535, both included).

      • BackendProtocol: The protocol for routing traffic to backend VMs (HTTP | HTTPS | TCP | SSL).

      • LoadBalancerPort: The port on which the load balancer is listening (between 1 and 65535, both included).

      • LoadBalancerProtocol: The routing protocol (HTTP | HTTPS | TCP | SSL).

      • PolicyNames: The names of the policies. If there are no policies enabled, the list is empty.

      • ServerCertificateId: The OUTSCALE Resource Name (ORN) of the server certificate. For more information, see Resource Identifiers > OUTSCALE Resource Names (ORNs).

    • LoadBalancerName: The name of the load balancer.

    • LoadBalancerStickyCookiePolicies: The policies defined for the load balancer.

      • CookieExpirationPeriod: The time period, in seconds, after which the cookie should be considered stale.
        If 1, the stickiness session lasts for the duration of the browser session.

      • PolicyName: The name of the stickiness policy.

    • LoadBalancerType: The type of load balancer. Valid only for load balancers in a Net.
      If LoadBalancerType is internet-facing, the load balancer has a public DNS name that resolves to a public IP.
      If LoadBalancerType is internal, the load balancer has a public DNS name that resolves to a private IP.

    • NetId: The ID of the Net for the load balancer.

    • PublicIp: (internet-facing only) The public IP associated with the load balancer.

    • SecuredCookies: Whether secure cookies are enabled for the load balancer.

    • SecurityGroups: One or more IDs of security groups for the load balancers. Valid only for load balancers in a Net.

    • SourceSecurityGroup: Information about the source security group of the load balancer, which you can use as part of your inbound rules for your registered VMs.
      To only allow traffic from load balancers, add a security group rule that specifies this source security group as the inbound source.

      • SecurityGroupAccountId: The account ID of the owner of the security group.

      • SecurityGroupName: The name of the security group.

    • Subnets: The ID of the Subnet in which the load balancer was created.

    • SubregionNames: The ID of the Subregion in which the load balancer was created.

    • Tags: One or more tags associated with the load balancer.

      • Key: The key of the tag, with a minimum of 1 character.

      • Value: The value of the tag, between 0 and 255 characters.

  • ResponseContext: Information about the context of the response.

    • RequestId: The ID of the request.

Result sample
{
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  },
  "LoadBalancer": {
    "Tags": [],
    "SourceSecurityGroup": {
      "SecurityGroupName": "security-group-example",
      "SecurityGroupAccountId": "123456789012"
    },
    "SecuredCookies": false,
    "Subnets": [
      "subnet-12345678"
    ],
    "NetId": "vpc-12345678",
    "BackendVmIds": [],
    "ApplicationStickyCookiePolicies": [],
    "SecurityGroups": [
      "sg-12345678"
    ],
    "LoadBalancerType": "internal",
    "AccessLog": {
      "PublicationInterval": 60,
      "IsEnabled": false
    },
    "DnsName": "internal-example-lbu.123456789.eu-west-2.lbu.outscale.com",
    "HealthCheck": {
      "UnhealthyThreshold": 2,
      "Timeout": 5,
      "CheckInterval": 30,
      "Protocol": "TCP",
      "HealthyThreshold": 10,
      "Port": 80
    },
    "LoadBalancerStickyCookiePolicies": [],
    "SubregionNames": [
      "eu-west-2a"
    ],
    "Listeners": [],
    "LoadBalancerName": "example-lbu"
  }
}

Ajouter ou supprimer des listeners avec AWS CLI

Ajouter un listener à un load balancer

Pour ajouter un ou plusieurs listeners à un load balancer, utilisez la commande create-load-balancer-listeners en suivant cette syntaxe :

Exemple de requête
$ aws elb create-load-balancer-listeners \
    --profile YOUR_PROFILE \
     --load-balancer-name LOAD_BALANCER_NAME \
    --listeners Protocol=TCP,LoadBalancerPort=62,InstanceProtocol=TCP,InstancePort=58 \
    --endpoint https://lbu.eu-west-2.outscale.com

Cette commande contient les attributs suivants que vous devez spécifier :

  • (optionnel) profile : Le profil nommé que vous voulez utiliser, créé pendant la configuration d’AWS CLI. Pour en savoir plus, voir Installer et configurer AWS CLI.

  • load-balancer-name : Le nom du load balancer.

  • listeners : Un ou plusieurs listeners pour le load balancer. Cet attribut requiert les éléments suivants pour chaque listener :

    Pour ajouter plusieurs listeners, séparez-les à l’aide d’une espace.

    • Protocol : Le protocole de routage pour le load balancer (HTTP, HTTPS, TCP ou SSL).

    • LoadBalancerPort : Le port sur lequel le load balancer écoute (entre 1 et 65535, tous deux inclus).

    • InstancePort : Le port sur lequel les instances backend écoutent (entre 1 et 65535, tous deux inclus).

    • (optionnel) InstanceProtocol : Le protocole utilisé pour router le trafic vers les instances backend (HTTP, HTTPS, TCP ou SSL).

    • (optionnel) SSLCertificateId : L’OUTSCALE Resource Name (ORN) d’un certificat SSL. Pour en savoir plus, voir Obtenir des informations sur vos certificats serveur.

      Un certificat SSL est requis si le protocole du load balancer est HTTPS ou SSL.

      Pour en savoir plus sur comment configurer votre listener lorsque vous utilisez des certificats SSL, voir Configurer un load balancer pour une redirection SSL.

  • endpoint : Le endpoint correspondant à la Région à laquelle vous voulez envoyer la requête.

Les listeners que vous avez spécifiés sont ajoutés au load balancer.

Supprimer un listener d’un load balancer

Pour supprimer un ou plusieurs listeners d’un load balancer, utilisez la commande delete-load-balancer-listeners en suivant cette syntaxe :

Exemple de requête
$ aws elb delete-load-balancer-listeners \
    --profile YOUR_PROFILE \
    --load-balancer-name LOAD_BALANCER-NAME \
    --load-balancer-ports 80 44 \
    --endpoint https://lbu.eu-west-2.outscale.com

Cette commande contient les attributs suivants que vous devez spécifier :

  • (optionnel) profile : Le profil nommé que vous voulez utiliser, créé pendant la configuration d’AWS CLI. Pour en savoir plus, voir Installer et configurer AWS CLI.

  • load-balancer-name : Le nom du load balancer.

  • load-balancer-ports : Un ou plusieurs ports correspondant aux listeners que vous souhaitez supprimer.

    Pour supprimer plusieurs listeners, séparez les avec un espace.

  • endpoint : Le endpoint correspondant à la Région à laquelle vous voulez envoyer la requête.

Les listeners que vous avez spécifiés sont supprimés du load balancer.

Pages connexes

Méthodes API correspondantes

AWS™ et Amazon Web Services™ sont des marques de commerce d’Amazon Technologies, Inc. ou de ses affiliées aux États-Unis et/ou dans les autres pays.