rightscale-cookbooks/rs-haproxymore_vert Ruby Last Updated: 2016-01-25T22:08:50Z

rs-haproxy cookbook

Release Build Status

Sets up HAProxy load balancer on a server. This cookbook also provides attributes and recipes to configure SSL on HAProxy and set up HAProxy as the front-end by attaching application servers to its back-end in a 3-tier deployment setup.

The HAProxy server identifies application servers in the same deployment by using machine tags. Refer to the rightscale_tag cookbook for more information on the machine tags set up on the servers in a RightScale environment.

Github Repository: https://github.com/rightscale-cookbooks/rs-haproxy



To install and configure HAProxy with SSL support

  • Add the rs-haproxy::default recipe to your run list.
  • To enable SSL in HAProxy set the node['rs-haproxy']['ssl_cert'] attribute to a PEM formatted string containing the SSL certificate and the credentials. If the node['rs-haproxy']['ssl_cert'] attribute is not set HAPRoxy will be configured without SSL support.

To configure HAProxy as the front-end

  • Add the rs-haproxy::frontend recipe to your run list.
  • Set the node['rs-haproxy']['pools'] attribute to a list of pool names that the HAProxy should serve.
  • Ensure that the application servers to be attached to HAProxy's back-end have application names same as one of the pool names served by HAProxy and the servers have the required machine tags set up. Refer to Application Servers section in the rightscale_tag cookbook for the machine tags set on the application servers.


  • node['rs-haproxy']['pools'] - The list of pools that the HAProxy answers. The order of the items in the list will be preserved when answering to requests. The last entry will be the default backend and will answer for all pools not listed here. The pool names can only have alphanumeric characters and underscores. Default: ['default']
  • node['rs-haproxy']['ssl_cert'] - PEM formatted string containing SSL certificates and keys for SSL encryption. If this attribute is set to nil, then HAProxy will be set up without support for SSL. Default: nil
  • node['rs-haproxy']['incoming_port'] - The port on which HAProxy listens for HTTP requests. Default is 80.
  • node['rs-haproxy']['ssl_incoming_port'] - The port on which HAProxy listens for HTTPS requests. Default is 443.
  • node['rs-haproxy']['stats_uri'] - The URI for the load balancer statistics report page. Default: /haproxy-status
  • node['rs-haproxy']['stats_user'] - Username for the load balancer statistics report page. Default: nil
  • node['rs-haproxy']['stats_password'] - Password for the load balancer statistics report page. Default: nil
  • node['rs-haproxy']['session_stickiness'] - Determines session stickiness. Setting to true, the load balancer will reconnect a session to the last server it was connected to (via a cookie). Default: true.
  • node['rs-haproxy']['health_check_uri'] - The URI that the load balancer will use to check the health of a server. Default: /
  • node['rs-haproxy']['balance_algorithm'] - The algorithm that the load balancer will use to direct traffic. Default: roundrobin
  • node['rs-haproxy']['backend']['inter'] - The "inter" parameter sets the interval between two consecutive health checks to milliseconds. Default: 300
  • node['rs-haproxy']['backend']['rise'] - The "rise" parameter states that a server will be considered as operational after consecutive successful health checks. Default: 3
  • node['rs-haproxy']['backend']['fall'] - 'The "fall" parameter states that a server will be considered as dead after consecutive unsuccessful health checks. Default: 2
  • node['rs-haproxy']['maxconn'] - 'Fix the maximum number of concurrent connections on a frontend'. Default: 4096



Installs HAProxy 1.5 by downloading the source package and compiling it. This recipe simply sets up the HAProxy configuration file using the haproxy LWRP, enables, and starts the HAProxy service. If the node['rs-haproxy']['ssl_cert'] attribute is set then this recipe will configure HTTPS support on the HAProxy server. All HTTP requests will be redirected to HTTPS in this scenario.


Tags the HAProxy server with the load balancer related machine tags. Refer to rightscale_tag cookbook for the list of tags set on a load balancer server. This recipe must be run to make the HAProxy server discoverable to the application servers in the deployment. The application servers can then attach to the HAProxy server by running the rs-haproxy::backend recipe.


Sets up monitoring for the HAProxy service. This recipe installs the HAProxy collectd plugin to monitor the HAProxy process.


This recipe can be used in two different contexts.

  • To attach all existing application servers in the deployment to the corresponding pools served by the HAProxy server. This recipe finds application servers in the deployment by querying for the application tags on the application server. Only the application servers whose application name matches one of the pool names in HAProxy are identified and attached to the HAProxy server.
  • To be run as a remote recipe for attaching/detaching a single application server to/from the HAProxy servers. To attach a single application server, the server invoking the remote recipe call should set node['remote_recipe']['application_action'] attribute to attach and pass its application name, bind IP address and port, server UUID, and the virtual host name to the HAProxy server. To detach a single application server, this attribute should be set to detach and the invoking server should pass its application name and the server UUID to the HAProxy server. Refer to rsrunrecipe utility for making remote recipe calls and passing information to the remote recipe.


Configure cron to periodically run rs-haproxy::frontend confirming that all application servers in the deployment are registered with HAProxy.


Downloads and installs hatop on the haproxy server, will install python also as it is a requirement


Author:: RightScale, Inc. (cookbooks@rightscale.com)

bryankaraffa/fish-dashmore_vert PHP Last Updated: 2016-02-21T18:06:10Z

bryankaraffa/torquemore_vert JavaScript Last Updated: 2016-03-30T18:26:51Z

This repo contains everything needed to setup an interface for uploading ODB2 data logged from your car in real-time using the Torque Pro app for Android.

The interface allows the user to:

  • View a Google Map showing your trips logged via Torque
  • Create time series plots of OBD2 data
  • Easily export data to CSV or JSON


Check out the demo!


These instructions assume you already have a LAMP-like server (on a Linux/UNIX based host) or have access to one. Specifically, you'll need the following:

  • MySQL database
  • Apache webserver
  • PHP server-side scripting

If in doubt, I'd recommend using Ubuntu LTS.

You also need a Bluetooth ODBII adapter, I recommend this one which I've used since 2014:

BAFX Products 34t5 Bluetooth OBDII Scan Tool for Android Devices

I also use this to position the adapter in a better location:

Oem OBD-II OBD2 16Pin Male to Female Extension Cable Diagnostic Extender 100cm

Server Setup

First clone the repo:

bash git clone https://github.com/surfrock66/torque cd torque

Configure MySQL

To get started, create a database named torque and a user with permission to insert and read data from the database. In this tutorial, we'll create a user steve with password zissou that has access to all tables in the database torque from localhost:

sql CREATE DATABASE torque; CREATE USER 'steve'@'localhost' IDENTIFIED BY 'zissou'; GRANT USAGE, FILE TO 'steve'@'localhost'; GRANT ALL PRIVILEGES ON torque.* TO 'steve'@'localhost'; FLUSH PRIVILEGES;

Then create a table in the database to store the logged data using the create_torque_log_table.sql, the create_torque_sessions_table.sql, and the create_torque_keys_table.sql files provided in the scripts folder of this repo:

bash mysql -u yoursqlusername -p < scripts/create_torque_log_table.sql mysql -u yoursqlusername -p < scripts/create_torque_sessions_table.sql mysql -u yoursqlusername -p < scripts/create_torque_keys_table.sql

OPTIONAL: Create Google Maps Javascript API Key

It's optional, but to be above board, you should create an API key for the google maps javascript API. If you go here Google Maps JavaScript API Click the "Get A Key" button, and follow the procedure to create a new project, then go to "Credentials" and make a new API Key, choosing "Server". You'll be using it below.

More guidance is available here.

You don't NEED to do this, but it's the proper way and will actually squash some javascript warnings if you like to keep your debug logs clean.

Configure Webserver

Move the contents of the web folder to your webserver and set the appropriate permissions. For example, using an Apache server located at /var/www:

bash mv web /var/www/torque cd /var/www/torque find . -type d -exec chmod 755 {} + find . -type f -exec chmod 644 {} +

Rename the creds-sample.php file to creds.php:

bash mv creds-sample.php creds.php

Then edit/enter your MySQL username and password in the empty $db_user and $db_pass fields:

php ... $db_host = 'localhost'; $db_user = '**steve**'; $db_pass = '**zissou**'; $db_name = 'torque'; $db_table = 'raw_logs'; $db_keys_table = 'torque_keys'; $db_sessions_table = 'sessions'; $gmapsApiKey = ''; // OPTIONAL Create a key at https://developers.google.com/maps/documentation/javascript/ ...

If you created a google maps API key above, place that in the variable here.

Settings in Torque App

To use your database/server with Torque, open the app on your phone and navigate to:

Settings -> Data Logging & Upload Below are the options which seem to work best for optimal logging, the suggested "File Logging" interval is 1s:

Additionally, I recommend changing the web logging interval to 1s, though this produces a LOT of data. Some users may want to set this to >=5s.

Enter the URL to your upload_data.php script under "Webserver URL" and press OK. Test that it works by clicking Test settings and you should see a success message like the image on the right:

At this point, you should be all setup. The next time you connect to Torque in your car, data will begin syncing into your MySQL database in real-time!


If you log a ton of PID's (as I do for debugging) you may encounter an apache bug; Torque uploads data through a huge $GET request. Apache, by default, allows $GET requests up to 8190 characters. My sample data upload was 13,619 characters long...this led to some data uploads returning 414 errors instead of 200 responses, which resulted in the app trying over-and-over to re-upload the datapoint, essentially DDoS'ing myself. For this; you can edit your apache configuration to allow any value you like; this is, in general, not recommended and should be set to limit a value as close as possible to what your longest query would be. On my configuration, I edited /etc/apache2/sites-available/000-default.conf and added the following line:

LimitRequestLine 15000


  • Sanity Checks and Warnings for merges and deletes
  • Allow for csv imports...captures un-uploaded but recorded data when emailed from torque
    • Email-receiver for this? LONG SHOT, but have the server read an email address so you can email tracks from the app
  • Ian Hawkins has a google map pin show up when hovering over his graphs on his reference viewer...different system, but it'd be cool to implement.
  • Idea: speed heatmap for the map track. (Google Maps iOS API has gradient polylines, javascript API does not...may not be possible for now).