Skip to content

Route to Multiple Services

Setting up traffic balancing between several Compute services

The user needs to order another service in Compute and configure it like the first service:
- install a web server;
- configure Firewall rules.

Web server installation

  1. Install a web server (example: apache):

    sudo yum install -y httpd
    
  2. Start the web server:

    sudo systemctl enable httpd —now
    
  3. Check if the web server is running:

    sudo systemctl status httpd
    

    Command Output Example

    httpd.service - The Apache HTTP Server
      Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
      Active: active (running) since Wed 2022-05-25 10:34:11 +03; 7s ago
        Docs: man:httpd.service(8)
    Main PID: 103004 (httpd)
      Status: "Started, listening on: port 80"
        Tasks: 213 (limit: 23512)
      Memory: 26.4M
      CGroup: /system.slice/httpd.service
              ├─103004 /usr/sbin/httpd -DFOREGROUND
              ├─103005 /usr/sbin/httpd -DFOREGROUND
              ├─103006 /usr/sbin/httpd -DFOREGROUND
              ├─103007 /usr/sbin/httpd -DFOREGROUND
              └─103008 /usr/sbin/httpd -DFOREGROUND
    
    May 25 10:34:11 alb-demo1.pt35.cmp.loc.icdc.io systemd[1]: Starting The Apache HTTP Server...
    May 25 10:34:11 alb-demo1.pt35.cmp.loc.icdc.io systemd[1]: Started The Apache HTTP Server.
    May 25 10:34:11 alb-demo1.pt35.cmp.loc.icdc.io httpd[103004]: Server configured, listening on: port 80
    

Auxiliary commands for running the web server

  • Reload configuration (when changing configuration files):
sudo systemctl reload httpd
  • Restart the web server:
sudo systemctl restart httpd
  • Checking the operation of the web server: Add any text to the /var/www/html/index.html file, for example: “Hello from alb-demo1.pt35.cmp.loc.icdc.io”:

    Example

    [root@alb-demo1 ~]# curl http://localhost
    Hello from alb-demo1.pt35.cmp.loc.io
    

Configuring the Firewall system

  1. By default, the system firewall blocks all HTTP and HTTPS traffic that comes from the outside on ports 80 and 443. To disable blocking, you need to add the HTTP and HTTPS services to the firewall rules.
    To do this, you need to run the commands:

    sudo firewall-cmd —permanent —zone=public —add-service=http
    sudo firewall-cmd —permanent —zone=public —add-service=https
    

    In order for the rules to apply, you need to reload the firewall configuration:
    sudo firewall-cmd —reload

    Check that the rules are set:

    sudo firewall-cmd —list-all
    
    public (active)
      target: default
      icmp-block-inversion: no
      interfaces: eth0
      sources: 
      services: cockpit dhcpv6-client http https ssh
      ports: 
      protocols: 
      forward: no
      masquerade: no
      forward-ports: 
      source-ports: 
      icmp-blocks: 
      rich rules: 
    
  2. Create a new web route alb-demo.pt35.cmp.loc.io:

  3. In the Target services, in the Weight fields, you need to specify in what proportions the traffic will be divided between the services (in this case, 1 to 1). Thus, you can divide the traffic between a large number of services.