How to Configure Firewall Rules for Vultr Load Balancer

Updated on November 27, 2024

Configuring Firewall Rules for Vultr Load Balancer allows you to control the traffic that can reach your load-balanced applications. By setting up firewall rules, you can specify which IP addresses and ports are allowed or blocked, enhancing the security of your services. This feature helps protect your backend servers from unauthorized access and potential threats by filtering incoming traffic based on your defined criteria.

Follow the steps below to configure firewall rules for your Vultr Load Balancer using the Vultr Customer Portal, API, or CLI.

  • Vultr Customer Portal
  • Vultr API
  • Vultr CLI
  1. Navigate to Products and click Load Balancer.

    Load Balancer option in products menu

  2. Click your target Load Balancer to open its management page.

    Selection of a target Load Balancer

  3. Click Configuration.

    Button to open Load Balancer configuration window

  4. Click Networking.

    Button to open Networking window

  5. Add a firewall rule, provide Port, IP Type and a Source.

    Fields to add a new firewall rule to the Load Balancer

  6. Click Save Changes.

    Button to save firewall rule changes

  1. Send a GET request to the List Load Balancer endpoint and note the target Load Balancer's ID.

    console
    $ curl "https://api.vultr.com/v2/load-balancers" \
        -X GET \
        -H "Authorization: Bearer ${VULTR_API_KEY}"
    
  2. Send a PATCH request to the Update Load Balancer endpoint to add a firewall rule to the target Load Balancer's algorithm.

    console
    $ curl "https://api.vultr.com/v2/load-balancers/<loadbalancer-id>" \
        -X PATCH \
        -H "Authorization: Bearer ${VULTR_API_KEY}" \
        -H "Content-Type: application/json" \
        --data '{
            "firewall_rules": [
            {
                "port": 80,
                "source": "0.0.0.0/0",
                "ip_type": "v4"
            }
            ]
    }'
    
  1. List the available Load Balancers and note the target Load Balancer's ID.

    console
    $ vultr-cli load-balancer list
    
  2. Add firewall rule to the target Load Balancer.

    console
    $ vultr-cli load-balancer update <loadbalancer-id> --firewall-rules="port:80,ip_type:v4,source:0.0.0.0/0"