Note : This blog post of mine is for general reference and I don't provide any sort of expert advice here. Yeah you can contact me through comment below for any queries and I will try to answer those.
I was discussing with my friend regarding one of his problem related to multiple Word Press (on different domain) hosting on same server and single static IP Address. Well at the time of our discussion he had configured two domain name based virtual host on Apache Httpd server installed on the physical box running Ubuntu 10.04 LTS.
As he started talking about the problems which he was facing as traffic on both of his websites are increasing, I realized he need to upgrade his System to handle high traffics.
Well For solving his problem up to an extend we had decided to use web accelerator like Varnish or Squid in front of Apache Httpd. Both of the web cache proxy is here for a while and proven with good track record. While researching onto Web Accelerator I encountered the Apache Traffic Server, which has become top level project on Apache in span of 2 years. Well I had gone through the benchmark results for all the three and found Apache Traffic Server to leading the chart. (See the reference section for detail)
Well I was very excited to bootstrap Apache Traffic Server to work as cache proxy for two domain name based Virtual Host hosted on single IP. Please read further to know more about the installation, basic configuration, logging and cache optimization. I guess its really an interesting stuff.
Intro - Apache Traffic Server
Apache Traffic Server is a reverse proxy, cache proxy and forward proxy. Web proxy caching enables you to store copies of frequently-accessed web objects (such as documents, images, and articles) and then serve this information to users on demand. It improves performance and frees up Internet bandwidth for other tasks.
Official website for Apache Traffic Server is http://trafficserver.apache.org.
Similar products: Varnish (https://www.varnish-cache.org)
Installation of Apache Traffic Server is bit tricky on Ubuntu due to absence of standard apt-get easy installer package. Well but its not that difficult though. I am writing down step by step process for easy understandability.
- Download latest tar.bz2 from apache website and put that on ubuntu server any directory.
- CD to directory where you had kept the downloaded and then uploaded tar.bz2 file
- $ tar xf trafficserver-x.y.z.tar.bz2
- $ cd trafficserver-x.y.z
- sudo apt-get install g++ libssl-dev tcl-dev libexpat1-dev libpcre3-dev libcap-dev libcap2 (Dependency packages need to be install, it will be used for making the package on current system)
- $ make (This will build with a destination prefix of /usr/local.)
- $ sudo make install (This finished the installation)
Server Level Configuration
- After successful installation, open ld.so.conf ($ sudo nano /etc/ld.so.conf) and add following line .include /usr/local/libexec/trafficserver
- Run the following command: sudo ldconfig
Start and stop
To start Traffic Server manually, issue the following command, passing in the attribute start. This command starts all the processes that work together to process Traffic Server requests as well as manage, control, and monitor the health of the Traffic Server system.
$ sudo trafficserver start/stop
All the configuration parameter related to cache are located in /usr/local/etc/trafficserver/records.config file after making any configuration changes do run command traffic_line -x to apply the configuration changes.
When we install traffic server, we had not provide the installation directories for config files and executable. These stuffs has been placed with default conventions.
All configurations files :
All executables :
Important Configuration Files & Usage
$ sudo nano /usr/local/etc/trafficserver/records.config
For changing default port as well as connection time out etc. related data.
Don't forget to execute following command in case of minor rule change:
$ sudo traffic_line -x
In case of severe change like port etc please make sure you had restarted the server:
$ sudo trafficserver restart
For Configuring the mapping
$ sudo nano /usr/local/etc/trafficserver/remap.config
In the above file, we can provide as many map, reverse map, redirect, reverse redirect configurations.
Apache Virtual Host Specific ConfigurationStep 1: $ sudo nano /usr/local/etc/trafficserver/records.config
In the file make following changes so config read like below
CONFIG proxy.config.reverse_proxy.enabled INT 1
CONFIG proxy.configurl_remap.remap_required INT 1
Step 2: $ sudo traffic_line -x
Step 3: $ sudo nano /usr/local/etc/trafficserver/remap.config
reverse_map http://www.abc.com:8090/ http://www.abc.com/
map http://www.xyz.com/ http://www.xyz.com:8090/
reverse_map http://www.xyz.com:8090/ http://www.xyz.com/
Note: Apache Httpd is running on port 8090
Step 2: $ sudo traffic_line -x
Above configuration is sufficient for setting the initial reverse proxy to listen on default port and serve the request based on domain name from provider (Apache)
In coming blocks we will configure and talk about the Caching and Logging for better performance and management.
Document for Reverse Proxy Setup.
proxy.config.cache.ram_cache.size INT -1 (default value 1 MB per 1 GB Disk Space, alternatively you can set 20971520 (20 MB))
Monitoring Traffic & Log File
Log file location - var/log/trafficserver
- Ubuntu Installation : http://linuxpoison.blogspot.com.ar/2011/07/installation-and-configuration-of.html
- Benchmark Apache Traffic Server vs Varnish : http://kpayne.me/2012/04/10/apache-traffic-server-as-a-reverse-proxy/
- Super tutorial : http://daemonkeeper.net/735/apache-trafficserver-the-better-web-cache/
- Official Administration Document : http://trafficserver.apache.org/docs/trunk/admin/