<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>lighty's life: Reverse-Proxying mod_proxy_core</title>
    <link>http://blog.lighttpd.net/articles/2006/07/18/reverse-proxying-mod_proxy_core</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Reverse-Proxying mod_proxy_core</title>
      <description>&lt;p&gt;I just added and commited the header rewriting support for mod_proxy_core.&lt;/p&gt;


&lt;pre&gt;
$HTTP["url"] =~ "^/proxyme(/|$)" {
  proxy-core.balancer = "round-robin" 
  proxy-core.protocol = "http" 
  proxy-core.backends = ( "en.wikipedia.org" )
  proxy-core.rewrite-response = (
    "Location" =&amp;gt; ( "^http://en.wikipedia.org/(.*)" =&amp;gt; "http://127.0.0.1:1025/proxyme/$1" ),
  )
  proxy-core.rewrite-request = (
    "_uri" =&amp;gt; ( "^/proxyme/?(.*)" =&amp;gt; "/$1" ),
    "Host" =&amp;gt; ( ".*" =&amp;gt; "en.wikipedia.org" ),
 )
}
&lt;/pre&gt;
&lt;kbd&gt;wget&lt;/kbd&gt; is happy now and follows redirect through the proxy as expected:

&lt;pre&gt;
$ wget http://127.0.0.1:1025/proxyme/
--15:18:20--  http://127.0.0.1:1025/proxyme/
           =&amp;gt; `index.html.1'
Connecting to 127.0.0.1:1025... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://127.0.0.1:1025/proxyme/wiki/Main_Page [following]
--15:18:20--  http://127.0.0.1:1025/proxyme/wiki/Main_Page
           =&amp;gt; `Main_Page'
Connecting to 127.0.0.1:1025... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
...
&lt;/pre&gt;

	&lt;p&gt;This implements &lt;a href="http://httpd.apache.org/docs/1.3/mod/mod_proxy.html#proxypassreverse"&gt;ProxyPassReverse&lt;/a&gt; in a very generic way. &lt;a href="http://httpd.apache.org/docs/1.3/mod/mod_proxy.html#proxypass"&gt;ProxyPass&lt;/a&gt; is the same as the Host: rewrite in the request.&lt;/p&gt;


	&lt;p&gt;Everything is controlled through the &lt;span class="caps"&gt;URL&lt;/span&gt;-conditional and limits the proxying to the &lt;kbd&gt;/proxyme/&lt;/kbd&gt; URL.&lt;/p&gt;</description>
      <pubDate>Tue, 18 Jul 2006 13:30:38 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:bda4250a-04e9-41ca-9afc-eb859f791c13</guid>
      <author>jan</author>
      <link>http://blog.lighttpd.net/articles/2006/07/18/reverse-proxying-mod_proxy_core</link>
      <trackback:ping>http://blog.lighttpd.net/articles/trackback/1777</trackback:ping>
    </item>
  </channel>
</rss>
