Complete the code to enable IP hash load balancing in nginx.
upstream backend {
[1];
server backend1.example.com;
server backend2.example.com;
}The ip_hash directive enables session persistence by routing requests from the same client IP to the same backend server.
Complete the nginx server block to proxy requests to the IP hash upstream.
server {
listen 80;
location / {
proxy_pass http://[1];
}
}The proxy_pass directive should point to the name of the upstream block, which is backend in this case.
Fix the error in this nginx upstream block to correctly enable IP hash.
upstream backend {
[1];
server backend1.example.com;
server backend2.example.com;
}The correct directive is ip_hash without any additional parameters like 'on'. It does not take 'on' or 'off'.
Fill both blanks to configure nginx to use IP hash and set a server with a specific port.
upstream backend {
[1];
server backend1.example.com[2];
server backend2.example.com;
}The ip_hash directive enables session persistence. The port :8080 specifies the backend server port.
Fill all three blanks to create a complete nginx configuration for IP hash session persistence with two backend servers on different ports.
upstream backend {
[1];
server backend1.example.com[2];
server backend2.example.com[3];
}This configuration uses ip_hash for session persistence. The two backend servers listen on ports 8080 and 9090 respectively.