Using Apache as proxy in port-forwarding role (inward to misbehaving NATted devices)

Matthew J. Roth mroth at imminc.com
Thu Jun 19 17:22:29 UTC 2008


Philip Prindeville wrote:
> The standard FC8 apache doesn't come with mod_proxy_html...  whither 
> might I find it?
>
> Or do I have to build from source?

Philip,

I suggest building it from source.  It's pretty simple and you're 
guaranteed to get a module that is compatible with your installation of 
Apache.

My application required building 'mod_proxy_html' and 'mod_headers'.  
You'll find my build and configuration notes below.  Be warned that my 
installation was on a CentOS 5 server, so you may need to make some 
small adjustments.

Once everything is built and configured, you'll have the 
'mod_proxy_html' directives (ProxyHTMLURLMap, ProxyHTMLExtended, etc.) and
'mod_headers' directives (Header, RequestHeader) available to you in 
your Apache configuration.  Note that it's important to use the

  SetOutputFilter proxy-html

directive, so that your HTML rewrites actually occur.

  * Build and Install the Apache Modules
    * mod_proxy_html
      * Install the prerequisite packages
        # yum -y install libxml2
          * Updated: libxml2.i386 0:2.6.26-2.1.2.1
        # yum -y install libxml2-devel
          * Updated: libxml2-devel.i386 0:2.6.26-2.1.2.1
      # cd /usr/src/
      # wget http://apache.webthing.com/mod_proxy_html/mod_proxy_html.tgz
      # tar -xzvf mod_proxy_html.tgz
      # cd mod_proxy_html/
      # /usr/local/apache2/bin/apxs -c -I/usr/include/libxml2 -i 
mod_proxy_html.c
 
    * mod_headers
      # mkdir /usr/src/mod_headers
      # cd /usr/src/mod_headers/
      # cp /usr/local/httpd-2.2.8/modules/metadata/mod_headers.c ./
      # /usr/local/apache2/bin/apxs -c -i mod_headers.c
 
  * Configure mod_proxy_html
    --- START /usr/local/apache2/conf/extra/httpd-proxy_html.conf 
------------------
    #
    # mod_proxy_html configuration
    #
    # See the documentation at http://apache.webthing.com/mod_proxy_html/
    #
    # Load the module with its prerequisites
    #
    LoadFile   /usr/lib/libxml2.so
    LoadModule proxy_html_module     modules/mod_proxy_html.so
    #
    # All knowledge of HTML links has been removed from the mod_proxy_html
    # code itself, and is instead read from httpd.conf (or included file)
    # at server startup.  So you MUST declare it.  This will normally be
    # at top level, but can also be used in a <Location>.
    #
    # Here's the declaration for W3C HTML 4.01 and XHTML 1.0
   
    ProxyHTMLLinks  a               href
    ProxyHTMLLinks  area            href
    ProxyHTMLLinks  link            href
    ProxyHTMLLinks  img             src longdesc usemap
    ProxyHTMLLinks  object          classid codebase data usemap
    ProxyHTMLLinks  q               cite
    ProxyHTMLLinks  blockquote      cite
    ProxyHTMLLinks  ins             cite
    ProxyHTMLLinks  del             cite
    ProxyHTMLLinks  form            action
    ProxyHTMLLinks  input           src usemap
    ProxyHTMLLinks  head            profile
    ProxyHTMLLinks  base            href
    ProxyHTMLLinks  script          src for
   
    # To support scripting events (with ProxyHTMLExtended On),
    # you'll need to declare them too.
   
    ProxyHTMLEvents onclick ondblclick onmousedown onmouseup \
                    onmouseover onmousemove onmouseout onkeypress \
                    onkeydown onkeyup onfocus onblur onload \
                    onunload onsubmit onreset onselect onchange
    --- END /usr/local/apache2/conf/extra/httpd-proxy_html.conf 
--------------------
 
  * Configure Apache
    * Add the following to the 'Dynamic Shared Object (DSO) Support' 
section of
      '/usr/local/apache2/conf/httpd.conf':
      --- START 'Dynamic Shared Object (DSO) Support' section ADDITIONAL 
CONTENTS ----
      # mod_headers
      LoadModule headers_module        modules/mod_headers.so
      --- END 'Dynamic Shared Object (DSO) Support' section ADDITIONAL 
CONTENTS ------
 
    * Add the following to the 'Supplemental configuration' section of
      '/usr/local/apache2/conf/httpd.conf':
      --- START 'Supplemental configuration' section ADDITIONAL CONTENTS 
-------------
      # mod_proxy_html
      Include conf/extra/httpd-proxy_html.conf
      --- END 'Supplemental configuration' section ADDITIONAL CONTENTS 
---------------

Regards,

Matthew Roth
InterMedia Marketing Solutions
Software Engineer and Systems Developer




More information about the users mailing list