Listeners

This section describes how to use listeners to check for incoming traffic on the load balancer's IP address.

Creating a Load Balancer Listener

You can create a listener for an existing load balancer (LB). The listener waits for traffic to arrive and is distributed to the backend server set collection of servers. You must list the traffic protocols that the LB accepts before you create the listener.

Using the Compute Web UI

  1. Open the Navigation Menu. Under Networking, click Load Balancers.

  2. Click the name of the Load Balancer for which you want to create the listener.

  3. Any existing listeners are listed under the Load Balancer Information, otherwise the list says No data available. To create a listener, click Create Listener.

  4. Enter the following information:

    • Name: Enter a descriptive name for the Listener.

    • Protocol: Select the protocol (HTTP, TCP) to listen for from the drop-down list.

    • Port: The default port value 80 for the listener is preselected. Use the up or down arrows to change the port value, or enter a value between 1 and 65,535.
    • Hostnames: Select the hostnames for the listener from the pull-down list. If the value is None Available, then you haven't yet created any LB hostnames and must do so before this parameter can be configured.

    • Backend Set: Select the backend set for the listener from the pull-down list. If the value is None Available, then you haven't yet created any LB backend sets and must do so before this parameter can be configured.

    • Idle Timeout in Seconds: The default value 60 seconds for the listener is preselected. Use the up or down arrows to change the idle timeout value, or enter a value greater than or equal to 1.
  5. Click the Create Listener button in the dialog. To display the details of the listener, you must view the details for the entire load balancer.

Using the OCI CLI

  1. Gather the information you need to run the command:

    • Compartment OCID (oci iam compartment list --compartment-id-in-subtree true)

    • LB OCID (oci lb load-balancer list --compartment-id compartment_OCID)

    • LB accepted protocol list (oci lb protocol list --compartment-id compartment_OCID)
  2. Run the listener create command.

    Use the LB OCID, backend set name, accepted protocol, and other details to create the listener for the LB backend server set in the specified compartment.

    Note:

    For information about optional parameters, run the command with the --help option.

    Syntax (entered on a single line):

    oci lb listener create --default-backend-set-name backend-set-name \
    --load-balancer-id load-balancer_OCID \  
    --name listener-name --port listener-port \
    --protocol listener-protocol  

    Where:

    backend-set-name is the name of the associated backend set. Example: example_backend_set

    load-balancer_OCID is the OCID of the load balancer on which to add a listener.

    listener_name is a user-friendly name for the listener. It must be unique and it can't be changed. Example: example_listener.

    listener-port is the communication port integer for the listener. Example: 80.

    listener-protocol is the protocol on which the listener accepts connection requests. Example: HTTP.

    Example:

    $ oci lb listener create --default-backend-set-name PublicLB1-Backend-Set \
    --load-balancer-id ocid1.loadbalancer....….….….uniqueID  \  
    --name LB1-Listener --port 80 --protocol HTTP  
    
    {
     "opc-work-request-id": "ocid1.workrequest.oc1.pca.loadbalancer...uniqueID"
    }

    Note:

    To see the listener results, you must list the entire load balancer details using the get command. You can't list listener properties by themselves.
    $ oci lb load-balancer get --load-balancer-id ocid1.loadbalancer....….….….uniqueID 
    
    {
      "data": {
        "backend-sets": {
          "PubLB1_BckEndSet": {
            "backends": [],
            "health-checker": {
              "interval-in-millis": 10000,
              "port": 80,
              "protocol": "HTTP",
              "response-body-regex": "HEALTH",
              "retries": 3,
              "return-code": 200,
              "timeout-in-millis": 3000,
              "url-path": "/"
              },
            "lb-cookie-session-persistence-configuration": null,
            "name": "PubLB1_BckEndSet",
            "policy": "LEAST_CONNECTIONS",
            "session-persistence-configuration": null,
            "ssl-configuration": null
            }
          },
        "certificates": {},
        "compartment-id": "ocid1.tenancy.… … ...unique_ID",
        "defined-tags": null,
        "display-name": "Pub_LB1",
        "freeform-tags": null,
        "hostnames": {
          "matchhostname1": {
            "hostname": "www.matchhost101.ie.oracle.com",
            "name": "matchhostname1"
            },
          "prehostname2": {
            "hostname": "*host1.ie.oracle.com",
            "name": "prehostname2"
            }
          },
        "id": "ocid1.loadbalancer.oc1.pca..… … ...unique_ID",
        "ip-addresses": null,
        "is-private": false,
        "lifecycle-state": "UNKNOWN_ENUM_VALUE",
        "listeners": {
          "LB1_Listener": {
            "connection-configuration": {
              "backend-tcp-proxy-protocol-version": null,
              "idle-timeout": 60
              },
            "default-backend-set-name": "PublicLB1-Backend-Set",
            "hostname-names": null,
            "name": "LB1_Listener",
            "path-route-set-name": null,
            "port": 80,
            "protocol": "HTTP",
            "routing-policy-name": null,
            "rule-set-names": null,
            "ssl-configuration": null
            }
          },
        "network-security-group-ids": null,
        "path-route-sets": {},
        "routing-policies": null,
        "rule-sets": {},
        "shape-details": null,
        "shape-name": "IGNORE",
        "ssl-cipher-suites": {},
        "subnet-ids": [
          "ocid1.subnet..… … ...unique_ID1"",
          "ocid1.subnet..… … ...unique_ID2""
          ],
        "system-tags": null,
        "time-created": "2022-08-30T18:25:31+00:00"
        },
      "etag": "9326dbb5-d842-4975-9cfb-ced7717e92d6"
    }

Editing a Load Balancer Listener

You can change load balancer (LB) listener properties, such as the listener communication port used.

Using the Compute Web UI

  1. Open the Navigation Menu. Under Networking, click Load Balancers.

  2. Under Resources, click Listeners.
  3. Select the name of the LB listener that you want to edit.

  4. In the Actions list, click Edit to open the Edit Load Balancer Listener window.

  5. Make allowable changes to the listener in the pop-up window.

  6. Click Update Load Balancer Listener to update the LB Listener properties.

Using the OCI CLI

  1. Gather the information you need to run the command:

    • Compartment OCID (oci iam compartment list --compartment-id-in-subtree true)

    • LB OCID (oci lb load-balancer list --compartment-id compartment_OCID)

  2. Run the update command.

    Note:

    For information about optional parameters, run the command with the --help option.

    Syntax (entered on a single line):

    oci lb listener update --default-backend-set-name [default-backendset-name] \ 
    --listener-name [listener-name] --load-balancer-id [loadbalancer_OCID]\
    --port [port-integer] --protocol [protocol-text]

    Where:

    default-backendset-name is the name of the associated backend set.

    listener-name is the name of the listener to update. Example: example_listener

    loadbalancer_OCID is the OCID of the load balancer associated with the listener to update

    port-integer is the communication port for the listener. Example: 80.

    protocol-text is the protocol on which the listener accepts connection requests. Example: HTTP

    Example:

    $ oci lb listener update --default-backend-set-name PublicLB1-Backend-Set \ 
    --listener-name LB1_Listener --load-balancer-id ocid1.loadbalancer....….….….uniqueID \
    --port 80 --protocol HTTP

    Note:

    To see the listener results, you must list the entire load balancer details using the get command. You can't list listener properties by themselves.
    $ oci lb load-balancer get --load-balancer-id ocid1.loadbalancer....….….….uniqueID 
    
    {
      "data": {
        "backend-sets": {
          "PubLB1_BckEndSet": {
            "backends": [],
            "health-checker": {
              "interval-in-millis": 10000,
              "port": 80,
              "protocol": "HTTP",
              "response-body-regex": "HEALTH",
              "retries": 3,
              "return-code": 200,
              "timeout-in-millis": 3000,
              "url-path": "/"
              },
            "lb-cookie-session-persistence-configuration": null,
            "name": "PubLB1_BckEndSet",
            "policy": "LEAST_CONNECTIONS",
            "session-persistence-configuration": null,
            "ssl-configuration": null
            }
          },
        "certificates": {},
        "compartment-id": "ocid1.tenancy.… … ...unique_ID",
        "defined-tags": null,
        "display-name": "Pub_LB1",
        "freeform-tags": null,
        "hostnames": {
          "matchhostname1": {
            "hostname": "www.matchhost101.ie.oracle.com",
            "name": "matchhostname1"
            },
          "prehostname2": {
            "hostname": "*host1.ie.oracle.com",
            "name": "prehostname2"
            }
          },
        "id": "ocid1.loadbalancer.oc1.pca..… … ...unique_ID",
        "ip-addresses": null,
        "is-private": false,
        "lifecycle-state": "UNKNOWN_ENUM_VALUE",
        "listeners": {
          "LB1_Listener": {
            "connection-configuration": {
              "backend-tcp-proxy-protocol-version": null,
              "idle-timeout": 60
              },
            "default-backend-set-name": "PublicLB1-Backend-Set",
            "hostname-names": null,
            "name": "LB1_Listener",
            "path-route-set-name": null,
            "port": 80,
            "protocol": "HTTP",
            "routing-policy-name": null,
            "rule-set-names": null,
            "ssl-configuration": null
            }
          },
        "network-security-group-ids": null,
        "path-route-sets": {},
        "routing-policies": null,
        "rule-sets": {},
        "shape-details": null,
        "shape-name": "IGNORE",
        "ssl-cipher-suites": {},
        "subnet-ids": [
          "ocid1.subnet..… … ...unique_ID1"",
          "ocid1.subnet..… … ...unique_ID2""
          ],
        "system-tags": null,
        "time-created": "2022-08-30T18:25:31+00:00"
        },
      "etag": "9326dbb5-d842-4975-9cfb-ced7717e92d6"
    }

Deleting a Load Balancer Listener

You can delete a load balancer (LB) Listener and remove it from service.

Using the Compute Web UI

  1. Open the Navigation Menu. Under Networking, click Load Balancers.

  2. Under Resources, click Listeners.
  3. Select the name of the LB listener you want to delete.

  4. Under the Actions column, click the three-dots pull-down menu, and select Terminate.

  5. Confirm the operation when prompted.

Using the OCI CLI

  1. Gather the information you need to run the command:

    • Compartment OCID (oci iam compartment list --compartment-id-in-subtree true)

    • LB OCID (oci lb load-balancer list --compartment-id compartment_OCID)

  2. Run the delete command.

    Syntax (entered on a single line):

    $ oci lb listener delete --listener-name listener-name-text \
     --load-balancer-id ocid1.loadbalancer....….….….uniqueID 
    Are you sure you want to delete this resource? [y/N]: y

    Note:

    To delete the LB listener without verification, run the command with the --force option.