HTML and CSS Reference
In-Depth Information
any time, then we simply have to put something in front of those services that can handle
routing the traffic correctly, based on the cloud topology at the moment. One way to
take down servers and bring up new ones without affecting service availability is to use
a proxy. In most cases, HAProxy is the go to-choice for high throughput and availability.
HAProxy is a lightweight proxy server that advertises obscenely high throughput. Such
companies as github, Fedora, Stack Overflow, and Twitter all use HAProxy for load
balancing and scaling their infrastructure. Not only can HAProxy handle HTTP traffic,
but it's also a general-purpose TCP/IP proxy. Best of all, it's dead simple to use.
The code that follows adds HAProxy to the previous example. The result is a reverse
proxy on the WebSocket port (8081), which allows all traffic (HTTP and WS) to be sent
across a common port (8080, in this case). Here is a simple reverse proxy from the
example WebSocket server:
global
maxconn 4096 # Total Max Connections. This is dependent on ulimit
nbproc 1
defaults
mode http
frontend all 0.0.0.0:8080
timeout client 86400000
default_backend www_backend
acl is_websocket hdr(Upgrade) -i WebSocket
acl is_websocket hdr_beg(Host) -i ws
use_backend socket_backend if is_websocket
backend www_backend
balance roundrobin
option forwardfor # This sets X-Forwarded-For
timeout server 30000
timeout connect 4000
server apiserver 192.168.1.101:8080 weight 1 maxconn 4096 check
backend socket_backend
balance roundrobin
option forwardfor # This sets X-Forwarded-For
timeout queue 5000
timeout server 86400000
timeout connect 86400000
server apiserver 192.168.1.101:8081 weight 1 maxconn 4096 check
This approach is universal to any HTTP server that embeds a separate WebSocket server
on a different port.
Search WWH ::




Custom Search