5๐
โ
You can do this with haproxy โ a robust software load balancer:
global
user haproxy
group haproxy
# chroot /usr/share/haproxy
pidfile /var/run/haproxy.pid
daemon
log 127.0.0.1 local0 info
defaults
log global
mode http
option httplog
option dontlognull
option redispatch
option httpclose
option forwardfor
balance roundrobin
retries 3
contimeout 5000
clitimeout 600000
srvtimeout 600000
frontend http_proxy :80
acl path_foo path_beg /foo
use_backend foo if path_foo
default_backend www
backend foo
server foo0 127.0.0.1:8080
backend www
server www0 127.0.0.1:8081
๐คMatt Billenstein
Source:stackexchange.com