Skip to main content

Configure HTTP load balancing for servers behind a FortiGate firewall

For your information

This guide provides an example of how to configure HTTP traffic load balancing between servers behind a firewall.

For your information

This instruction is relevant for FortiOS versions 6.x and 7.x. If you have a different version of FortiOS, you can find instructions in the official FortiGate documentation.

  1. If you have not yet linked FortiGate to servers, connect the FortiGate firewall to servers in the Selectel infrastructure.
  2. Create a health check.
  3. Create a virtual server.
  4. Create a security policy.
  5. Check load balancing operation.

1. Connect the FortiGate firewall to the servers in the Selectel infrastructure

Use the Connect products and services via global router instructions.

2. Create a health check

Health Check determines the operability of a server behind the firewall based on configured parameters. If a server behind the firewall stops responding, FortiGate will redirect requests to available servers.

  1. Connect to the firewall.
  2. Make sure that under System → Feature Visibility, the Load Balance toggle is enabled. If the toggle is disabled, the sections with load balancing settings will not be displayed.
  3. Go to Policy & Objects → Health Check.
  4. Click Create New.
  5. In the Name field, enter the name of the health check.
  6. In the Type field, select the health check protocol HTTP.
  7. In the Interval field, enter the check frequency for the server behind the firewall in seconds or leave the default value.
  8. In the Timeout field, enter the maximum response timeout from the server behind the firewall in seconds or leave the default value.
  9. In the Retry field, enter the number of failed health checks after which the server behind the firewall will be excluded from load balancing, or leave the default value.
  10. In the Port field, enter the port to check the availability of the server behind the firewall. By default, it is port 80.
  11. In the URL field, enter the path to the file on the server behind the firewall to which FortiGate will send a GET request to check the server's availability. For example, /health.html.
  12. In the Matched content field, enter the text that FortiGate will look for in the GET request response body. For example, OK.
  13. Click OK.

3. Create a virtual server

A Virtual Server accepts incoming traffic and redirects it to real servers (Real Server) — the IP address and port of the server behind the firewall. You can add multiple real servers so that FortiGate automatically distributes the load between them.

  1. Connect to the firewall.

  2. Go to Policy & Objects → Virtual Servers.

  3. Click Create New.

  4. In the Name field, enter the name of the virtual server.

  5. In the Type field, select the HTTP protocol.

  6. In the Interface field, select through which firewall interface requests will arrive at the virtual server:

    • to receive requests only through one interface, select this interface. For example, wan1;
    • to receive requests through all interfaces, select any.
  7. In the Virtual Server IP field, enter the public IP address of the firewall that you received in the ticket after ordering the firewall.

  8. In the Virtual Server Port field, enter the port on the firewall that incoming requests will arrive at.

  9. In the Load Balancing Method field, select a load balancing method.

  10. Optional: so that all requests from a single user within a session are processed by one server behind the firewall, in the Persistence field, select HTTP Cookie. Learn more about session persistence in the Session persistence section of the Load balancing protocols and methods instruction.

  11. In the Health Check field, select the health check you created in step 2.

  12. Optional: to use a single TCP connection with the server behind the firewall when processing multiple HTTP requests, enable the HTTP Multiplexing toggle.

  13. Optional: to preserve the user's IP address in the X-Forwarded-For HTTP header, enable the Preserve Client IP toggle.

  14. In the Real Servers section, click Create New.

  15. In the IP Address field, enter the private IP address of the server behind the firewall.

  16. In the Port field, enter the port of the server behind the firewall to which requests will be forwarded. By default, it is port 80.

  17. Click OK.

  18. Repeat steps 14–17 for every server behind the firewall that you want to add to load balancing.

  19. Click OK.

4. Create a security policy

A security policy determines what traffic the firewall will allow between its interfaces. For example, you can use a policy to allow HTTP traffic to a virtual server. If no security policies are created, all traffic is dropped.

  1. Connect to the firewall.
  2. Go to Policy & Objects → IPv4 Policy.
  3. Click Create New.
  4. In the Name field, enter the name of the security policy.
  5. In the Incoming Interface field, select the public interface of the firewall.
  6. In the Outgoing Interface field, select the private interface of the firewall.
  7. In the Source field, select all.
  8. In the Destination field, select the virtual server you created in step 3.
  9. In the Schedule field, select always.
  10. In the Service field, select HTTP.
  11. In the Action field, select Accept.
  12. In the Inspection Mode field, select Proxy-based.
  13. Disable the NAT toggle. The servers behind the firewall will receive the original connection IP addresses.
  14. Click OK.

5. Verify load balancing operation

  1. Connect to the firewall.

  2. Go to Monitor → Load Balance Monitor.

  3. In the Real Server column, next to the real server IP address, click .

  4. In the Status column, check the server status:

    • Up — the server is active, FortiGate forwards requests to it;
    • Down — the server is not responding, FortiGate does not forward requests to it.