Tuesday, October 18, 2016

// // Leave a Comment

How To Set Nginx as Load Balancer for CDN

Before Starting to set HaProxy, we need to setup 2 or more servers to set in the Load Balancer. Lets assume that we have set 3 servers with Nginx on them. In all servers modify the “add_header X-Proxy-Serve” line in order to name each server.

Now we have 3 servers and named them as CDN1, CDN2 and CDN3, we can now put a load balancer in front of them to complete our CDN setup.

Even though Nginx itself can be used as load balancer, we prefer to use HaProxy for our load balancer. On a new server, simply install Haproxy and modify haproxy.conf as follows:


When we start our HaProxy with this configuration, the requests will be equally distributed to our three Nginx servers. The configuration above assumes that Haproxy can communicate with Nginx servers on a private LAN. You can change these to public IPs if you don’t have a private network. In addition, you can view statistics of Haproxy on 9000 port to verify that each Nginx server is working on our simple CDN setup.


Read More

Saturday, August 20, 2016

// // Leave a Comment

ShareThis Asynchronous Javascript Loading

Unfortunately the ShareThis service has a lot of known issues, like loading a lot of data from their tracking site, b.scorecardresearch.com and other types of bloat when initializing their icons.
Because calling stLight.options depends on having the buttons.js script already loaded, it is not really feasible to initialize the code like this:

However, you could use an onload function to do the stLight.options, and then wrap the entire thing inside of a function that won’t interfere with the global namespace, like this:


Make sure to update your publisher ID in the code above if you copy / paste it.
Read More