HAProxy Enterprise Documentation 2.7r1

set server

Change a server's properties.

Description

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

Server property

Parameter

Ready / drain / maintenance state

state

IP address (IPv4 or IPv6). Optionally, change the port.

addr [port]

FQDN

fqdn

Weight

weight

Health status

health

Health check agent status

agent

Change the IP address used for server health checks. Optionally, change the port.

check-addr [port]

Port where health check probes are sent

check-port

IP address where the health check agent is listening. Optionally, change the port.

agent-addr [port]

Port where the health check agent is listening.

agent-port

Configure SSL on the server. Health check path is not changed by SSL mode. (Deprecated. Instead, use add-server to create a dynamic server having the desired parameters.)

ssl

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 unix-connect:/var/run/hapee-2.7/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 unix-connect:/var/run/hapee-2.7/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 unix-connect:/var/run/hapee-2.7/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 unix-connect:/var/run/hapee-2.7/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 unix-connect:/var/run/hapee-2.7/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 unix-connect:/var/run/hapee-2.7/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 unix-connect:/var/run/hapee-2.7/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 unix-connect:/var/run/hapee-2.7/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 unix-connect:/var/run/hapee-2.7/hapee-lb.sock

Optionally, you can append the port parameter to agent-addr to specify a new port for the agent.

You can also change the agent port without using the agent-addr parameter by just using the agent-port parameter by itself:

$ echo "set server webservers/s1 agent-port 49999" | \
   sudo socat stdio unix-connect:/var/run/hapee-2.7/hapee-lb.sock

The check-addr parameter changes the IP address used for server health checks. Optionally, add the port parameter to change the port.

$ echo "set server webservers/s1 check-addr 192.168.0.12 port 49999\n" | \
   sudo socat stdio unix-connect:/var/run/hapee-2.7/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 unix-connect:/var/run/hapee-2.7/hapee-lb.sock

Change SSL

Turn SSL ciphering on or off for outgoing server connections:

$ echo "set server webservers/s1 ssl on\n" | \
   sudo socat stdio unix-connect:/var/run/hapee-2.7/hapee-lb.sock

See also


Next up

set severity-output