Adding an HTTP Listener
Scenarios
HTTP listeners apply to applications that require data content identification, such as web applications and small mobile games.
Adding an HTTP Listener to a Shared Load Balancer
- Log in to the management console.
- In the upper left corner of the page, click
and select the desired region and project. - Click Service List. Under Network, click Elastic Load Balance.
- Locate the load balancer and click its name.
- Under Listeners, click Add Listener.
- Configure the listener based on Table 1 and click Next.
Table 1 Parameters for configuring a listener Parameter
Description
Example Value
Name
Specifies the listener name.
listener-pnqy
Frontend Protocol/Port
Specifies the protocol and port used by the load balancer to receive requests from clients and forward the requests to backend servers.
Port range: 1 to 65535
HTTP/80
Redirect
Specifies whether to enable redirection to redirect requests to an HTTPS listener when HTTP is used as the frontend protocol. If you have both HTTPS and HTTP listeners, you can use this function to redirect the requests from the HTTP listener to the HTTPS listener to ensure security.
After an HTTP listener is redirected, backend servers return HTTP 301 Move Permanently to the clients.
N/A
Redirected To
Specifies the HTTPS listener to which requests are redirected.
N/A
Advanced Settings
Access Policy
Specifies how access to the listener is controlled. For more information, see Access Control. The following options are available:
- All IP addresses
- Blacklist
- Whitelist
Blacklist
IP Address Group
Specifies the IP address group associated with a whitelist or blacklist. If there is no IP address group, create one first. For more information, see IP Address Group.
ipGroup-b2
Obtain Load Balancer EIP
Specifies whether to pass the load balancer EIP to backend servers.
You can enable this function only when you add listeners.
N/A
Idle Timeout
Specifies the length of time (in seconds) for a connection to be kept alive. If no request is received within this period, the load balancer closes the connection and establishes a new one with the client when the next request arrives.
60
Request Timeout
Specifies the length of time (in seconds) after which the load balancer closes the connection if the load balancer does not receive a request from the client.
60
Response Timeout
Specifies the length of time (in seconds) after which the load balancer sends a 504 Gateway Timeout error to the client if the load balancer receives no response from the backend server after routing a request to the backend server and receives no response after attempting to route the same request to other backend servers.
NOTE:If you have enabled sticky sessions and the backend server does not respond within the response timeout duration, the load balancer returns 504 Gateway Timeout to the clients.
60
Description
Provides supplementary information about the listener.
N/A
- Set backend server group parameters by referring to Table 2 and health check parameters by referring to Table 3, and click Finish.
Table 2 Parameters for configuring a backend server group Parameter
Description
Example Value
Backend Server Group
Specifies a group of servers that have the same features and receive requests from the load balancer. Two options are available:
- Create new
- Use existing NOTE:
To associate an existing backend server group, ensure that it is not in use. Select the backend server group with the correct protocol. For example, if the frontend protocol is TCP, the backend protocol can only be TCP.
Create new
Name
Specifies the name of the backend server group.
server_group-sq4v
Backend Protocol
Specifies the protocol used by backend servers to receive requests. The backend protocol is HTTP by default.
HTTP
Load Balancing Algorithm
Specifies the algorithm used by the load balancer to distribute traffic.
- Weighted round robin: Requests are distributed across backend servers in sequence based on their weights. Backend servers with higher weights receive proportionately more requests, whereas equal-weighted servers receive the same number of requests.
- Weighted least connections: This algorithm is designed based on the least connections algorithm that uses the number of active connections to each backend server to make its load balancing decision. In addition to the number of connections, each server is assigned a weight based on its capacity. Requests are routed to the server with the lowest connections-to-weight ratio.
- Source IP hash: The source IP address of each request is calculated using the consistent hashing algorithm to obtain a unique hash key, and all backend servers are numbered. The generated key allocates the client to a particular server. This allows requests from different clients to be routed based on source IP addresses and ensures that a client is directed to the same server that it was using previously.
NOTE:- Choose an appropriate algorithm based on your requirements for better traffic distribution.
- For Weighted round robin or Weighted least connections, no access request will be routed to a server if its weight is 0.
Weighted round robin
Sticky Session
Specifies whether to enable sticky sessions. If you enable sticky sessions, all requests from the same client during one session are sent to the same backend server.
NOTE:- Sticky sessions can be enabled only if you select Weighted round robin or Weighted least connections for Load Balancing Algorithm.
- Enabling or disabling sticky sessions may interrupt services for a few seconds.
N/A
Sticky Session Type
Specifies the type of sticky sessions. Both Load balancer cookie and Application cookie are available when you have set Frontend Protocol to HTTP. Choose an appropriate sticky session type to better distribute requests and improve load balancing.
- Load balancer cookie: The load balancer generates a cookie after receiving a request from the client. All subsequent requests with the cookie are routed to the same backend server for processing.
- Application cookie: The application deployed on the backend server generates a cookie after receiving the first request from the client. All requests with the cookie are routed to this backend server.
Load balancer cookie
Cookie Name
Specifies the cookie name. If you have selected Application cookie, enter a cookie name.
cookieName-qsps
Stickiness Duration (min)
Specifies the minutes that sticky sessions are maintained. Set the stickiness duration if you have selected Weighted round robin as the load balancing algorithm and Load balancer cookie as the sticky session type. The stickiness duration ranges from 1 to 1440.
20
Description
Provides supplementary information about the backend server group.
N/A
Table 3 Parameters for configuring a health check Parameter
Description
Example Value
Enable Health Check
Specifies whether to enable health checks.
N/A
Protocol
Specifies the protocol used by the load balancer to perform health checks on backend servers. You can select either TCP or HTTP. You cannot modify the protocol after the listener is added to the load balancer.
HTTP
Domain Name
Specifies the domain name in the health check request. The domain name can contain digits, letters, hyphens (-), and periods (.), and must start with a digit or letter. This parameter is left blank by default and needs to be set only when the health check protocol is HTTP.
www.elb.com
Port
Specifies the port used by the load balancer to perform health checks on backend servers.
Port range: 1 to 65535
NOTE:This parameter is optional. If you do not specify a health check port, the port of each backend server will be used for health checks by default.
80
Advanced Settings
Interval (s)
Specifies the maximum time between health checks, in seconds.
The interval ranges from 1 to 50.
5
Timeout (s)
Specifies the maximum time required for waiting for a response from the health check, in seconds. The timeout duration ranges from 1 to 50.
10
Check Path
Specifies the health check URL, which is the destination on backend servers for health checks. This parameter is available only if you set Protocol to HTTP. The path can contain 1 to 80 characters and must start with a slash (/).
/index.html
Maximum Retries
Specifies the maximum number of health check retries. The value ranges from 1 to 10.
3
- Click OK.
Adding an HTTP Listener to a Classic Load Balancer
- Log in to the management console.
- In the upper left corner of the page, click
and select the desired region and project. - Click Service List. Under Network, click Elastic Load Balance.
- In the classic load balancer list, locate the load balancer and click its name.
- Under Listeners, click Add Listener. In the Add Listener dialog box, specify the parameters by referring to Table 4.
Table 4 Parameter description Parameter
Description
Example Value
Name
Specifies the listener name.
listener-ssgu
Frontend Protocol/Port
Specifies the protocol and port used by the load balancer to receive requests from clients and forward the requests to backend servers.
Port range: 1 to 65535
HTTP/80
Backend Protocol/Port
Specifies the protocol and port used by backend servers to receive requests.
The protocol is HTTP by default, and the port numbers range from 1 to 65535.
HTTP/22
Load Balancing Algorithm
Specifies the algorithm used by the load balancer to distribute traffic. The following options are available:
- Round robin: Requests are distributed sequentially across all servers, so that the load is evenly shared.
- Least connections: a dynamic scheduling algorithm that estimates backend server load based on the number of active connections. Requests are routed to servers with the minimum number of connections.
- Source IP hash: The source IP address of each request is calculated using the consistent hashing algorithm to obtain a unique hash key, and all backend servers are numbered. The generated key allocates the client to a particular server. This allows requests from different clients to be routed based on source IP addresses and ensures that a client is directed to the same server that it was using previously.
NOTE:Choose an appropriate algorithm based on your requirements for better traffic distribution.
Round robin
Sticky Session
Specifies whether to enable sticky sessions.
If you enable sticky sessions, all requests from a client during one session are sent to the same backend server.
NOTE:You can enable sticky sessions only if you have set Load Balancing Algorithm to Round robin.
N/A
Stickiness Duration (min)
Specifies the minutes that sticky sessions are maintained. The stickiness duration ranges from 1 to 1440.
5
Description
Provides supplementary information about the listener.
N/A
Health Check Protocol/Port
Specifies the protocol and port used for performing health checks on backend servers.
Specifies the protocol used by the load balancer to perform health checks on backend servers. You can use either TCP or HTTP. A selected protocol cannot be changed.
Port range: 1 to 65535
HTTP/80
Interval (s)
Specifies the maximum time between health checks, in seconds.
The interval ranges from 1 to 50.
5
Timeout (s)
Specifies the maximum time required for waiting for a response from the health check, in seconds.
The timeout duration ranges from 1 to 50.
10
Healthy Threshold
Specifies the number of consecutive health checks necessary for a backend server to be considered healthy. The threshold ranges from 1 to 10.
3
Unhealthy Threshold
Specifies the number of consecutive health checks necessary for a backend server to be considered unhealthy. The threshold ranges from 1 to 10.
3
Check Path
Specifies the health check URL, which is the destination on backend servers for health checks. This parameter is available only if you set Health Check Protocol to HTTP. The path can contain 1 to 80 characters and must start with a slash (/).
NOTE:The path can contain only letters, digits, and the following special characters: -/.%?#&_=
/test.html
- Click OK.
Last Article: Adding a UDP Listener
Next Article: Adding an HTTPS Listener
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.