Thursday, September 30, 2010

Running Apache Traffic Server on Fedora 13

Apache Traffic server from Yahoo! Inc. is really powerful, extensible web server which is proved to serve 75K reqs/sec on commodity hardware.

In this post, you'll learn how to download and run the Traffic server on your desktop, notebook.


1. Download TrafficServer 2.0.1 (latest as of 30-Sep-2010)

http://trafficserver.apache.org/downloads.html

2. Install the following packages



[nareshv@fallenangel ~]$ sudo yum install autoconf automake \
libtool gcc-c++ glibc-devel \
openssl-devel tcl-devel \
expat-devel sqlite-devel \
pcre-devel -y



3. Extract the trafficserver and build it



[nareshv@fallenangel ~]$ tar jxf trafficserver-2.0.1.tar.bz2
[nareshv@fallenangel ~]$ cd trafficserver-2.0.1
[nareshv@fallenangel trafficserver-2.0.1]$ ./configure
[nareshv@fallenangel trafficserver-2.0.1]$ gmake
[nareshv@fallenangel trafficserver-2.0.1]$ sudo gmake install



Now, all the required files would be installed in "/usr/local" instead of Fedora's default /usr. Lets configure Traffic server to act as ReverseProxy for apache

5. set servername of your proxy (so that it will come up in the HTTP headers)



[nareshv@fallenangel ~]$ sudo vim /usr/local/etc/trafficserver/records.config

# Change line 22 (it might vary) to put your hostname like shown below
22 #CONFIG proxy.config.proxy_name STRING <proxy_name>
22 CONFIG proxy.config.proxy_name STRING fallenangel




6. Make the Traffic server listen on port 80 by default



[nareshv@fallenangel ~]$ sudo vim /usr/local/etc/trafficserver/records.config

# Change 8080 port to 80 like shown below
105 #CONFIG proxy.config.http.server_port INT 8080
105 CONFIG proxy.config.http.server_port INT 80



7. Make Traffic server act as reverse proxy for apache

You can add as many rules as you want. The configuration file is well defined


[nareshv@fallenangel ~]$ sudo vim /usr/local/etc/trafficserver/remap.config

124
125 map http://localhost:80/ http://localhost:8080/
126 map http://fallenangel:80/ http://localhost:8080/




8. configure apache to listen on port 8080



[nareshv@fallenangel ~]$ sudo vim /etc/httpd/conf/httpd.conf
# Change it from default port 80 to 8080
#Listen 80
Listen 8080



9. Restart apache



[nareshv@fallenangel ~]$ sudo /etc/init.d/httpd restart



10. Restart traffic server



[nareshv@fallenangel ~]$ sudo /usr/local/bin/trafficserver restart
Stopping traffic_cop: [ OK ]
Stopping traffic_manager: [ OK ]
Stopping traffic_server: [ OK ]
Starting Apache Traffic Server: [ OK ]



11. Make simple request to your TrafficServer to test if everything is ok



[nareshv@fallenangel ~]$ ~]$ curl -v http://localhost/
* About to connect() to localhost port 80 (#0)
* Trying ::1... Connection refused
* Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.20.1 (x86_64-redhat-linux-gnu) libcurl/7.20.1 NSS/3.12.6.2 zlib/1.2.3 libidn/1.16 libssh2/1.2.4
> Host: localhost
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Date: Thu, 30 Sep 2010 09:47:53 GMT
< Server: ATS/2.0.1
< Content-Type: text/html; charset=iso-8859-1
< Age: 0
< Transfer-Encoding: chunked
< Connection: keep-alive
< Via: HTTP/1.1 fallenangel (ApacheTrafficServer/2.0.1 [cMs f ])
<
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL / was not found on this server.</p>
<hr>
<address>Apache/2.2.16 (Fedora) Server at localhost Port 8080</address>
</body></html>
* Connection #0 to host localhost left intact
* Closing connection #0

2 comments:

  1. Your requested URL was not found.

    ReplyDelete
  2. Unknown Host

    Description: Unable to locate the server named "localhost (2)" --- the server does not have a DNS entry. Perhaps there is a misspelling in the server name, or the server no longer exists. Double-check the name and try again.

    ReplyDelete