Configuring a web server failover

This recipe describes how to configure a small webfarm using the pfSense load balancer.

Getting ready

The load balancer also allows pfSense to send traffic to a failover server in case of downtime. In the following recipe, we will configure a backup webserver to take place of the primary in the event of downtime.

How to do it...

  1. Browse to Services | Load Balancer.
  2. Click the Monitor tab.
  3. Click the "plus" button to add a new monitor.
  4. Specify a Name.
  5. Add a Description.
  6. Set Type to HTTP.
  7. Set Host to the IP address of our primary webserver.
  8. Leave HTTP Code set to 200 OK:
    How to do it...
  9. Save the changes.
  10. Apply changes, if necessary:
    How to do it...
  11. Click the Pools tab.
  12. Click the "plus" button to add a new pool.
  13. Specify a Name.
  14. Set the Mode to Manual Failover.
  15. Add a Description.
  16. Set the Port to 80 (since we're creating a webserver failover).
  17. Set Monitor to our newly created WebFailoverMonitor.
  18. Specify the Server IP Address of the primary webserver and click Add to pool. The IP address will appear in the Enabled (default) list.
  19. Specify the Server IP Address of the backup webserver and click Add to pool. The IP address will appear in the Pool Disabled list:
    How to do it...
  20. Save the changes.
  21. Apply changes, if necessary:
    How to do it...
  22. Click the Virtual Servers tab.
  23. Click the "plus" button to add a new virtual server.
  24. Specify a Name.
  25. Add a Description.
  26. Set the IP Address to an unused IP address.
  27. Set Port to 80 (since we're dealing with a webserver failover).
  28. Set Virtual Server Pool to our newly created WebFailoverPool:
    How to do it...
  29. Submit the changes.
  30. Apply changes, if necessary:
    How to do it...

How it works...

Throughout this recipe, we've configured pfSense to automatically redirect traffic from the primary webserver to the backup webserver in the event of a failure. Our pool defines the location of the webservers and the failover mode (as opposed to load balance). Our virtual server defines the IP address we will use in our NAT and firewall rules to listen for the HTTP requests, which the virtual server redirects to the pool we've defined. The monitor will check on the status of the primary webserver by periodically making a web request. If the response coming back is 200 OK, then the pool will send traffic to the primary server; otherwise, it will send traffic to the backup server.

See also

  • The Creating a NAT port forward rule recipe in Chapter 3, General Configuration
  • The Creating a firewall rule recipe in Chapter 3, General Configuration
  • The Configuring a web server load balancer recipe
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.13.116