<?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>Erics Tech Blog &#187; Apache</title>
	<atom:link href="http://eric.lubow.org/category/system-administration/apache-system-administration/feed/" rel="self" type="application/rss+xml" />
	<link>http://eric.lubow.org</link>
	<description>Thoughts, musings, and other idealistic (sometimes useful) systems and development hoopla.</description>
	<lastBuildDate>Fri, 18 Nov 2011 14:56:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>Apache mod_proxy</title>
		<link>http://eric.lubow.org/2008/system-administration/apache-system-administration/apache-mod_proxy/</link>
		<comments>http://eric.lubow.org/2008/system-administration/apache-system-administration/apache-mod_proxy/#comments</comments>
		<pubDate>Tue, 16 Sep 2008 14:00:10 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[proxy]]></category>

		<guid isPermaLink="false">http://eric.lubow.org/?p=65</guid>
		<description><![CDATA[I came up against the interesting problem of putting multiple stand alone apache tomcat instances with different virtual host names on the same machine that all needed to be accessible via port 80 (on the same IP). There is always mod_jk, but that seems like a bit too much to fix a simple problem. Being [...]]]></description>
			<content:encoded><![CDATA[<p>I came up against the interesting problem of putting multiple stand alone apache tomcat instances with different virtual host names on the same machine that all needed to be accessible via port 80 (on the same IP).  There is always mod_jk, but that seems like a bit too much to fix a simple problem.  Being a strong believer in the right tool for the right job, I came across mod_proxy.  This way I get to take advantage of apache connection handling without having to put a whole proxy server in front of it.  Because there is dispatching by virtual host to do, putting apache in front just seemed to be the best idea.</p>
<p>Since there aren&#8217;t too many clear HOWTOs on this, it took a bit of fudging.  Here is what you need to know.</p>
<p>Let&#8217;s create the host <em>http://port8080.lubow.org/</em> to go to <em>http://8080.lubow.org:8080/</em>.  </p>
<p>The first thing is a fairly common default configuration of <strong>NameVirtualHost</strong> option.  This is so you can have multiple virtual hosts per IP.  Unless you are crazy (or have a really good reason), you do not want to create an open proxy.  So you need to globally configure the <strong>ProxyRequests</strong> variable to be off.  Do the base setup for a VirtualHost of <strong>ServerName</strong> and <strong>ServerAdmin</strong>.</p>
<p>Setup the proxy authorizations (similar to the apache allow/denys).  In order for the right HTTP headers to make it to the proxy&#8217;d virtual host, the headers will need to be rewritten.  This needs to happen both going to the host and coming back from the host going to the client.  This is why there is the <strong>ProxyPass</strong> and <strong>ProxyPassReverse</strong>.  The first argument is the URL that on the virtual host that should match the URL (second argument) on the proxy&#8217;d virtual host.  The <strong><a href="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypreservehost">ProxyPreserveHost</a></strong> option is generally not needed (but it is for the specific application I am running.  Click the link above to read the description to determine whether it is right for you.</p>
<p>Putting it all together, you will get a file that looks like below.  Make sure you replace your IPs and hostnames with what&#8217;s appropriate for your environment.</p>
<div class="codecolorer-container apache default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="apache codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #00007f;">ProxyRequests</span> <span style="color: #0000ff;">Off</span><br />
<span style="color: #00007f;">NameVirtualHost</span> 1.2.3.4:<span style="color: #ff0000;">80</span><br />
<br />
&lt;<span style="color: #000000; font-weight:bold;">virtualhost</span> 1.2.3.4:<span style="color: #ff0000;">80</span>&gt;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #00007f;">ServerAdmin</span> webmaster@lubow.org<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">ServerName</span> port8080.lubow.org<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;<span style="color: #000000; font-weight:bold;">proxy</span> *&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f;">Order</span> <span style="color: #00007f;">deny</span>,<span style="color: #00007f;">allow</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f;">Allow</span> from <span style="color: #0000ff;">all</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/<span style="color: #000000; font-weight:bold;">proxy</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">ProxyPreserveHost</span> &nbsp; <span style="color: #0000ff;">On</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">ProxyPass</span> &nbsp; / http://<span style="color: #ff0000;">8080</span>.lubow.org:<span style="color: #ff0000;">8080</span>/<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">ProxyPassReverse</span> &nbsp; &nbsp;/ http://<span style="color: #ff0000;">8080</span>.lubow.org:<span style="color: #ff0000;">8080</span>/<br />
&lt;/<span style="color: #000000; font-weight:bold;">virtualhost</span>&gt;</div></div>


<p>Related posts:<ol><li><a href='http://eric.lubow.org/2007/system-administration/a-few-apache-tips/' rel='bookmark' title='A Few Apache Tips'>A Few Apache Tips</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://eric.lubow.org/2008/system-administration/apache-system-administration/apache-mod_proxy/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

