<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Web2.0 Tutorials &#187; Apache</title>
	<atom:link href="http://www.zulutown.com/blog/category/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zulutown.com/blog</link>
	<description>All the Guides You Need to Become a Web2.0 Expert</description>
	<lastBuildDate>Wed, 24 Aug 2011 10:06:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Change your site domain or path keeping your Google PageRank and position</title>
		<link>http://www.zulutown.com/blog/2009/04/01/change-your-site-domain-or-path-keeping-your-google-pagerank-and-position/</link>
		<comments>http://www.zulutown.com/blog/2009/04/01/change-your-site-domain-or-path-keeping-your-google-pagerank-and-position/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 19:45:04 +0000</pubDate>
		<dc:creator>Zulutown Webmaster</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[301]]></category>
		<category><![CDATA[domain name]]></category>
		<category><![CDATA[google first position]]></category>
		<category><![CDATA[google pr]]></category>
		<category><![CDATA[http 301]]></category>
		<category><![CDATA[location]]></category>
		<category><![CDATA[moved]]></category>
		<category><![CDATA[pagerank]]></category>
		<category><![CDATA[permanent redirect]]></category>
		<category><![CDATA[pr]]></category>
		<category><![CDATA[redirect]]></category>
		<category><![CDATA[redirectmatch]]></category>
		<category><![CDATA[regular expression]]></category>
		<category><![CDATA[relative path]]></category>
		<category><![CDATA[relocate]]></category>
		<category><![CDATA[search engine]]></category>
		<category><![CDATA[url]]></category>
		<category><![CDATA[wget]]></category>

		<guid isPermaLink="false">http://www.zulutown.com/blog/?p=105</guid>
		<description><![CDATA[When a website moves from an URL to another, the main issue for the webmaster is try to keep a good position on the Google search results (or other search engines). Time ago I applied the SEO technique described in this article and I obtained good results. The goal, in this example, is to move [...]]]></description>
			<content:encoded><![CDATA[<p>When a website moves from an URL to another, the main issue for the webmaster is try to keep a good position on the Google search results (or other search engines).<br />
Time ago I applied the <strong>SEO technique</strong> described in this article and I obtained good results.</p>
<p>The goal, in this example, is to move the site located in <code>http://www.youroldsite.com/section/</code> to the new location <code>http://www.yournewsite.com/section/</code>.</p>
<p>The trick to map everything  to the new location (without specifying every single URL) and especially to tell correctly to Google to consider that the site has moved (as described in Google FAQ) is to use the HTTP response code <em>301</em> that causes a <strong>Permanent Redirect</strong>.</p>
<p>Obviously everything inside the <code>section</code> directory must keep exactly its previous relative path. I.e. <code>http://www.youroldsite.com/section/page.html</code> have to be placed in <code>http://www.yournewsite.com/section/page.html</code>.<br />
It&#8217;s even possible, using regular expression, to map relative paths that have some differences, but a &#8220;logic&#8221; between them should exist.</p>
<p>A <code>.htaccess</code> file should be placed inside the <em>document root</em> or in the <code>section</code> subdirectory of the <strong>old</strong> website where the site is moving out<br />
The content of <code>.htaccess</code> should look like this:</p>
<pre>RedirectMatch 301 ^/section/(.*)$ http://www.yournewsite.com/section/$1</pre>
<p>Obviously if the new site has <code>section</code> moved in <code>othersection</code> the <code>.htaccess</code> should look like this:</p>
<pre>RedirectMatch 301 ^/section/(.*)$ http://www.yournewsite.com/othersection/$1</pre>
<p>And if the relocation has happened within the same domain:</p>
<pre>RedirectMatch 301 ^/section/(.*)$ /othersection/$1</pre>
<p>A test made with <code>wget</code> (a GNU tool):</p>
<pre>Connecting to www.youroldsite.com|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://www.yournewsite.com/section/ [following]
--2009-03-24 20:04:59--  http://www.yournewsite.com/section/
Resolving www.yournewsite.com... 127.0.0.1
Connecting to www.yournewsite.com|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 200 OK</pre>
<p>I applied the first configuration to one of my websites that was in the first position on Google for some <em>query strings</em>, because unluckily I had to move it on a new domain name.</p>
<p>The result has been very good. After 7 days I placed the <em>Redirect 301</em>, my old URL (that was the first position of Google) has been replaced by the new one. Still in the <strong>first position</strong>, and it&#8217;s still there!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zulutown.com/blog/2009/04/01/change-your-site-domain-or-path-keeping-your-google-pagerank-and-position/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Java EE Load Balancing with Tomcat and Apache</title>
		<link>http://www.zulutown.com/blog/2009/02/16/java-ee-load-balancing-with-tomcat-and-apache/</link>
		<comments>http://www.zulutown.com/blog/2009/02/16/java-ee-load-balancing-with-tomcat-and-apache/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 21:16:45 +0000</pubDate>
		<dc:creator>Zulutown Webmaster</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Tomcat]]></category>
		<category><![CDATA[ajp]]></category>
		<category><![CDATA[balancermember]]></category>
		<category><![CDATA[cluster]]></category>
		<category><![CDATA[connector]]></category>
		<category><![CDATA[jsessionid]]></category>
		<category><![CDATA[jvmroute]]></category>
		<category><![CDATA[load balancer]]></category>
		<category><![CDATA[load balancing]]></category>
		<category><![CDATA[mod_proxy]]></category>
		<category><![CDATA[mod_proxy_ajp]]></category>
		<category><![CDATA[mod_proxy_balancer]]></category>
		<category><![CDATA[stickysession]]></category>

		<guid isPermaLink="false">http://www.zulutown.com/blog/?p=78</guid>
		<description><![CDATA[This tutorial explains how to configure an Apache HTTPD server to map a specific path on a series of load-balanced Apache Tomcat. The first step is to define the Virtual Host in the Apache configuration files. In this case the root directory (on file system) of the site is located in /path/to/your/site/, the name of [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial explains how to configure an <em>Apache HTTPD</em> server to map a specific path on a series of load-balanced <em>Apache Tomcat</em>.<br />
The first step is to define the <em>Virtual Host</em> in the Apache configuration files.<br />
In this case the root directory (on file system) of the site is located in <code>/path/to/your/site/</code>, the name of the site is <code>www.yoursite.com</code> and the path where the Tomcat servers may be reached is <code>/javaee</code>.</p>
<p>In few words, an URL like <code>http://www.yoursite.com/home.html</code> is mapped on the file <code>/path/to/your/site/home.html</code>.</p>
<p>An URL like <code>http://www.yoursite.com/javaee/hello.jsp</code> is mapped to the <code>hello.jsp</code> file contained in <code>javaee.war</code> application deployed on all the Tomcat servers defined in the <em>load balanced cluster</em>.</p>
<p>The configuration of the Apache virtual host:</p>
<pre>&lt;VirtualHost *&gt;
	ServerAdmin webmaster@localhost
	ServerName www.yoursite.com
	DocumentRoot /path/to/your/site/
	&lt;Directory /path/to/your/site/&gt;
		Options MultiViews
		AllowOverride All
		Order allow,deny
		allow from all
	&lt;/Directory&gt;

	ErrorLog /var/log/yoursite-error.log

	LogLevel warn

	CustomLog /var/log/yoursite-access.log combined

    &lt;Proxy balancer://tomcatservers&gt;
	BalancerMember ajp://tomcatserver.yoursite.com:8009 route=tomcatA retry=60
        BalancerMember ajp://tomcatserver.yoursite.com:8010 route=tomcatB retry=60
	BalancerMember ajp://tomcatserver.yoursite.com:8011 route=tomcatC retry=60
    &lt;/Proxy&gt;

    &lt;Location /javaee&gt;
	Allow From All
        ProxyPass balancer://tomcatservers/javaee stickysession=JSESSIONID nofailover=off
    &lt;/Location&gt;

&lt;/VirtualHost&gt;</pre>
<p>The most important settings are <code>Proxy</code> and <code>Location</code>.<br />
In <code>Proxy</code> it&#8217;s defined a <em>load balancer</em> made with 3 tomcat servers and an URL is assigned to the balancer, in this case <code>balancer://tomcatservers</code>.</p>
<p>The balancer has three members, everyone with its own URL based on the <code>ajp</code> protocol. In this case Apache will connect to the Tomcat servers on their <em>AJP connectors</em> (an alternative would be to use their <em>HTTP connectors</em>).</p>
<p>The Tomcat servers run on the <code>tomcatserver.yoursite.com</code> hostname and each of them opens its own AJP connector on a different port: the first on <code>8009</code> (the default one), the second on <code>8010</code>, the third on <code>8011</code> (obviously if they run on the same hostname/IP they must bind to different ports).</p>
<p>Each Tomcat is identified by a route name: <code>tomcatA</code>, <code>tomcatB</code> and <code>tomcatC</code>. The importance of it will be explained later.</p>
<p>In the <code>Location</code> section, a specific path <code>/javaee</code> of the virtual host is mapped on the previously defined balancer <code>balancer://tomcatservers/javaee</code>. So when someone asks for <code>http://www.yoursite.com/javaee/hello.jsp</code> the virtual host will request that JSP to a randomly chosen Tomcat in the balancer members.</p>
<p>What&#8217;s the <code>stickysession</code> attribute? It&#8217;s a very useful configuration parameter used in conjunction with the <code>route</code> attributes, defined before.</p>
<p>As probably every Java EE (or Web) developer should know, while browsing on a server, it keeps trace of some data about the browsing session in a server-side <em>HttpSession</em> object. For example an ecommerce web application needs to store somewhere the information about the shopping cart of non registered users.</p>
<p>How the server can associate the remote session data with the specific navigation session? This is done through a cookie (or via a GET parameter in the URL) that gives to the server the <em>session ID</em> value.</p>
<p>In Java EE applications, the cookie name to identify the sessions is <code>JSESSIONID</code>.</p>
<p>This is closely related to the management of the load balancing between the Tomcat servers.</p>
<p>If Apache picked randomly one of the Tomcat to handle a single request and if the next request from the same user/browser was forwarded by the balancer <em>to another Tomcat</em> in that battery, things wouldn&#8217;t work correctly.</p>
<p>Each Tomcat doesn&#8217;t know anything of the existence of other Tomcat in that balancer configuration and especially a single Tomcat server cannot access the information of <em>http sessions</em> handled by another Tomcat.</p>
<p>In few words, when a Tomcat is chosen to handle the first request from a user/browser, it&#8217;s absolutely required that, to keep valid session data, the same Tomcat must be used to handle the following requests coming from that browser/user.</p>
<p>If not, on each request, the session data would be lost and simple tasks, such as building a shopping cart would result impossible.</p>
<p>So, it&#8217;s required to tell to Apache what is the session cookie name: <code>JSESSIONID</code> and which is the identifier of the routes to each single tomcat Server: <code>tomcatA</code>, <code>tomcatB</code>, <code>tomcatC</code>.</p>
<p>In this way, Apache will append to the end of the cookie value the information about the route to the specific Tomcat.</p>
<div id="attachment_83" class="wp-caption aligncenter" style="width: 490px"><img class="size-large wp-image-83" title="Java EE Tomcat Load Balancing" src="http://www.zulutown.com/blog/wp-content/uploads/2009/02/javaee-tomcat-load-balancing-480x320.png" alt="Java EE Tomcat Load Balancing" width="480" height="320" /><p class="wp-caption-text">Java EE Tomcat Load Balancing</p></div>
<p>Finally, the last thing to set-up Apache, is obviously to add to it the  modules required by the previous configuration:</p>
<ul>
<li>proxy</li>
<li>proxy_balancer</li>
<li>proxy_ajp</li>
</ul>
<p>About Tomcat configuration, there are just few changes to apply to the default configuration, in the <code>Engine</code> section it&#8217;s required to add the <code>jvmRoute</code> attribute.</p>
<pre>&lt;Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcatA"&gt;</pre>
<p>This is related to the <code>route</code> parameter defined in the Apache load balancer. So, <code>tomcatA</code> should be set in the configuration of the first Tomcat server, <code>tomcatB</code> in the second and <code>tomcatC</code> in the third one.</p>
<p>Then, the port where <em>AJP connector</em> listens, has to be set accordingly to the apache configuration, so <code>8009</code>, <code>8010</code>, <code>8011</code> respectively on the first, second and third Tomcat.</p>
<p>The following is the the configuration of the <em>AJP connector</em>:</p>
<pre>&lt;Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /&gt;</pre>
<p>It&#8217;s not directly related to the setup of the load-balancer, but since they run on the same host, each Tomcat should have its own set of ports.</p>
<p>To prevent any conflict you should change the following settings on the second and third servers: <code>Server port="8005"</code> and <code>Connector port="8080"</code>.</p>
<p>I hope this tutorial has given a complete overview about every step required to setup <em>Apache</em> and <em>Tomcat</em> to create a simple load-balanced cluster.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zulutown.com/blog/2009/02/16/java-ee-load-balancing-with-tomcat-and-apache/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

