Virtual Server is very useful, but currently only supports a single port (in CLI). The virtual server seems to be a huge improvement on NAT, and being able to add multiple ports would be incredibly helpful.
Something along the lines of:
set high-availability virtual-server 203.0.113.1 algorithm 'source-hashing'
set high-availability virtual-server 203.0.113.1 delay-loop '10'
set high-availability virtual-server 203.0.113.1 forward-method 'nat'
set high-availability virtual-server 203.0.113.1 persistence-timeout '180'
set high-availability virtual-server 203.0.113.1 rule 10 port '8280'
set high-availability virtual-server 203.0.113.1 rule 10 protocol 'tcp'
set high-availability virtual-server 203.0.113.1 rule 10 real-server 192.0.2.11 port '80'
set high-availability virtual-server 203.0.113.1 rule 10 real-server 192.0.2.12 port '80'
set high-availability virtual-server 203.0.113.1 rule 20 port '443'
set high-availability virtual-server 203.0.113.1 rule 20 protocol 'tcp'
set high-availability virtual-server 203.0.113.1 rule 20 real-server 192.0.2.11 port '443'
set high-availability virtual-server 203.0.113.1 rule 20 real-server 192.0.2.12 port '443'
Perhaps even support for port groups i.e.
set high-availability virtual-server 203.0.113.1 rule 10 group port-group 'http_https'
set high-availability virtual-server 203.0.113.1 rule 10 protocol 'tcp'
set high-availability virtual-server 203.0.113.1 rule 10 real-server 192.0.2.11 group port-group 'http_https'
As far as I can understand, keepalived does support multiple ports, and the configuration is exactly the same as for a single port - just another block with the new port and config i.e.:
Port groups might be slightly more difficult, and I would assume looping through the ports in the group and adding groups for each of them - which may for all I know be exactly how groups are treated in other parts of the system.
Does it not solve with fwmark for different ports?
Virtual server it just any name in this case and all decision will be match mark and real server configs
set high-availability virtual-server foo rule 20 fwmark ‘111’
set high-availability virtual-server bar rule 20 fwmark ‘112’
Hi. I just tested this and think it would be good to allow multiple virtual hosts on the same IP but on different ports, translated to other real server ports, without having to resort to fwmark (not even sure fwmark can do that). Something like this:
set high-availability virtual-server 1.2.3.4:80 real-server 5.6.7.8 port 8080
set high-availability virtual-server 1.2.3.4:443 real-server 5.6.7.8 port 8443
Perhaps add a prefix node to specify the type of virtual server (host:port, fwmark or virtual server group). .
set high-availability virtual-server address_port 1.2.3.4:80 real-server 5.6.7.8 port 8080
set high-availability virtual-server fwmark 111 real-server 5.6.7.8
set high-availability virtual-server group my_group ...
The type could technically be decoded from the node name itself even without the prefix
A virtual_server can be a declaration of one of <IPADDR> [<PORT>] , fwmark <INTEGER> or group <STRING>
The syntax for virtual_server is :
virtual_server <IPADDR> [<PORT>] |
virtual_server fwmark <INTEGER> |
virtual_server group <STRING> {
...
}
Having an easy way to do loadbalancing is a somewhat unique feature these days in both firewalls and routers.
That is be able to do this through the “set high-availability virtual-server” without having to involve a 3rd party solution such as F5, A10 or Kemp among others or internally without having to do some ninjawork with fwmarks etc.
On the other hand while looking at this in version VyOS 1.4-rolling-202306290317 wouldnt the below do just whats being asked or am I missing something here?
high-availability {
virtual-server 1.2.3.4:80 {
algorithm round-robin
delay-loop 10
forward-method direct
persistence-timeout 180
port 80
protocol tcp
real-server 2.2.2.2 {
port 8080
}
real-server 3.3.3.3 {
port 8080
}
}
virtual-server 1.2.3.4:443 {
algorithm round-robin
delay-loop 10
forward-method direct
persistence-timeout 180
port 443
protocol tcp
real-server 2.2.2.2 {
port 8443
}
real-server 3.3.3.3 {
port 8443
}
}
}
If reverse-proxy in VyOS also can do non-http requests (DNS, SMTP etc) then whats the difference between virtual-server and reverse-proxy?
In my world a reverse-proxy have always been limited to http/https requests (and because of that it can also operate on the http(s) request itself including ssl/tls stuff including acting as ssl-termination that is client connects to the reverse-proxy using https but once the request is forwarded to the backend it can be decrypted as plain http).
Reverse proxy doesn’t support UDP packets.
Different backends. keepalived-ipvsadm vs haproxy. If you need udp balancing or several marked ports you should use of course ha virtual-server
From looking at the j2 template that creates the keepalived.conf file if you use the addr:port syntax as a virtual server conf node, you will afaict end up with the wrong syntax in the .conf file.
virtual_server 1.2.3.4:80 80 {}
instead of virtual_server 1.2.3.4 80 {}