HAProxy Enterprise Documentation 1.6r1

set server

Change a server's properties.

Description

Use the set server command to change the following properties of a backend server:

Server property

set server command parameter

Ready / drain / maintenance state

state

IP address (IPv4 or IPv6) and port

addr

FQDN

fqdn

Weight

weight

Health status

health

Health check agent status

agent

Port where health check probes are sent

check-port

IP address where the health check agent is listening

agent-addr

String that the load-balancer sends to the agent during each health check

agent-send

Examples

Following are examples of using the set server command.

Change a server's state

Use the following state parameters, depending on your goals:

Receive traffic

Perform health checks

state parameter

Yes

Yes

ready

No

Yes

drain

No

No

maint

Below, we set the server's state to drain:

$ echo "set server webservers/s1 state drain" |
sudo socat stdio /var/run/hapee-1.6/hapee-lb.sock

Change a server's address and port

Below, we use the addr parameter to change the s1 server's IP address to 127.0.0.1:

$ echo "set server webservers/s1 addr 127.0.0.1" |
sudo socat stdio /var/run/hapee-1.6/hapee-lb.sock

Below, we change the server's IP address to 127.0.0.1 and its port to 8081:

$ echo "set server webservers/s1 addr 127.0.0.1 port 8081" |
sudo socat stdio /var/run/hapee-1.6/hapee-lb.sock

Change a server's FQDN

Suppose you've specified a fully qualified domain name (FQDN) for the server instead of an IP address, and you've added a resolvers parameter to use a resolvers section, as shown below:

resolvers mydns
   nameserver dns1 192.168.50.30:53
   accepted_payload_size 8192

backend webservers
   server s1 s1.example.com:8080 check resolvers mydns

You can use the fqdn parameter to change the server's domain name dynamically:

$ echo "set server webservers/s1 fqdn s1.example.local" |
sudo socat stdio /var/run/hapee-1.6/hapee-lb.sock

Change a server's weight

The weight parameter changes a server's weight. The value can be a percentage or an exact number. In the example below, we set the server's weight to 50% of its current value:

$ echo "set server webservers/s1 weight 50%" |
sudo socat stdio /var/run/hapee-1.6/hapee-lb.sock

Change active health checks

Use the following health parameters, depending on your goals:

Goal

health parameter

Take the server out of the load-balancing rotation.

down

Add the server back into the load-balancing rotation.

up

Drain traffic.

stopping

In the next example, the health parameter sets the server's health status to down, which takes it out of the load-balancing rotation.

$ echo "set server webservers/s1 health down" |
sudo socat stdio /var/run/hapee-1.6/hapee-lb.sock

The check-port parameter changes the port where health check probes are sent:

$ echo "set server webservers/s1 check-port 8080" |
sudo socat stdio /var/run/hapee-1.6/hapee-lb.sock

Change agent health checks

In the example below, the agent parameter sets the server's agent to a new state. You can set either up or down:

$ echo "set server webservers/s1 agent down" |
sudo socat stdio /var/run/hapee-1.6/hapee-lb.sock

The agent-addr parameter changes the IP address where the agent is listening:

$ echo "set server webservers/s1 agent-addr 192.168.0.11" |
sudo socat stdio /var/run/hapee-1.6/hapee-lb.sock

The agent-send parameter changes the string that the load balancer sends to the agent during each health check:

$ echo "set server webservers/s1 agent-send ping\n" |
sudo socat stdio /var/run/hapee-1.6/hapee-lb.sock

See also


Next up

set ssl ocsp-response