Virtual World Framework and HAProxy 1.5 How To Setup Configuration

8bbeb2ed9280551b8a845a530a690a8e

When setting up our operational environment on Amazon Web Services, we had a number of interesting constraints.

  • We were cost constrained to maintain the minimum number of servers possible.
  • We needed to support Jenkins for Continuous Integration and Redmine for Issue Tracking.
  • The VWF demonstrations utilize websockets and secure websockets which required us to support websockets / secure websockets.
  • We needed to support multiple subdomains which point to multiple Ruby Thin web servers/ Node.js web servers on the back-end to host our executing branch configurations from GitHub.
  • We needed to allow an SSL pathway for internal Lockheed network engineers to access.
  • We required compression
  • We required all traffic over port 80
  • We needed to reroute a subdomain to point to an sh script for installation hosted on GitHub

To solve these issues, HAProxy came in to save the day allowing us to achieve all of these goals by serving as our front-end service proxy for our operational environment to handle incoming client requests.  HAProxy 1.5, although still in development, is stable enough and capable of handling reverse proxying of websockets for HTML5 AND handles compression on the fly as well.

Below is our configuration file.  Please leave questions in the comments if you have any!

HAProxy Configuration for Virtual World Framework

————————————————————————————————–

global

log 127.0.0.1 local0
log 127.0.0.1 local1 notice
#log loghost local0 info
maxconn 4096
#chroot /usr/share/haproxy
user haproxy
group haproxy
daemon
debug
#quiet

defaults

log global
mode http
option httplog
option http-server-close
option dontlognull
retries 3
option redispatch
option contstats
option forwardfor
stats enable
stats refresh 10s
stats uri /stats
compression algo gzip
compression type text/html text/plain text/css model/vnd.collada+xml application/javascript
timeout connect 360s
timeout client 360s
timeout server 180s
timeout http-keep-alive 60s
timeout http-request 60s
timeout queue 60s
timeout tarpit 60s
timeout tunnel 3600s

frontend public

bind *:80
acl is_jenkins hdr_beg(host) -i jenkins.
acl is_redmine hdr_beg(host) -i redmine.
acl is_www hdr_beg(host) -i www.
acl is_integration hdr_beg(host) -i integration.
acl is_development hdr_beg(host) -i development.
acl is_download hdr_beg(host) -i download.
acl is_test hdr_beg(host) -i test.
acl is_get hdr_beg(host) -t get.
use_backend jenkins if is_jenkins
use_backend redmine if is_redmine
use_backend development if is_development
use_backend integration if is_integration
use_backend download if is_download
use_backend www if is_www
use_backend test if is_test
use_backend get if is_get
default_backend www

backend www

timeout server 30s
server www1 127.0.0.1:5000
acl hdr_connection_upgrade hdr(Connection) -i upgrade
acl hdr_upgrade_websocket hdr(Upgrade) -i websocket
acl hdr_websocket_key hdr_cnt(Sec-WebSocket-Key) eq 1
acl hdr_websocket_version hdr_cnt(Sec-WebSocket-Version) eq 1
acl hdr_host hdr_cnt(Sec-WebSocket-Version) eq 1

backend integration

timeout server 30s
server integration1 127.0.0.1:5001
acl hdr_connection_upgrade hdr(Connection) -i upgrade
acl hdr_upgrade_websocket hdr(Upgrade) -i websocket
acl hdr_websocket_key hdr_cnt(Sec-WebSocket-Key) eq 1
acl hdr_websocket_version hdr_cnt(Sec-WebSocket-Version) eq 1
acl hdr_host hdr_cnt(Sec-WebSocket-Version) eq 1

backend development

timeout server 30s
server integration1 127.0.0.1:5002
acl hdr_connection_upgrade hdr(Connection) -i upgrade
acl hdr_upgrade_websocket hdr(Upgrade) -i websocket
acl hdr_websocket_key hdr_cnt(Sec-WebSocket-Key) eq 1
acl hdr_websocket_version hdr_cnt(Sec-WebSocket-Version) eq 1
acl hdr_host hdr_cnt(Sec-WebSocket-Version) eq 1

backend test

timeout server 30s
server integration1 127.0.0.1:5003
acl hdr_connection_upgrade hdr(Connection) -i upgrade
acl hdr_upgrade_websocket hdr(Upgrade) -i websocket
acl hdr_websocket_key hdr_cnt(Sec-WebSocket-Key) eq 1
acl hdr_websocket_version hdr_cnt(Sec-WebSocket-Version) eq 1
acl hdr_host hdr_cnt(Sec-WebSocket-Version) eq 1

backend jenkins

timeout server 30s
server jenkins1 127.0.0.1:6001
option http-server-close
cookie JSESSIONID prefix

backend redmine

timeout server 180s
server redmine1 127.0.0.1:6000
option http-server-close
cookie JSESSIONID prefix

backend download

timeout server 180s
server download1 127.0.0.1:8081
option http-server-close
cookie JSESSIONID prefix

backend get

redirect location https://raw.github.com/virtual-world-framework/vwf/branch/vwf-install-scripts/support/build/Scripts/install.sh

 

Leave a Reply