Apache 2.0/2.2 Reverse Proxy

By Robert Mela.
Tags:

Table of Contents

Configuration

#
# Using Apache 2.0 and 2.2 as a reverse proxy
# for a Nitro application.
#
# Note that Apache 2.2 offers a load balancing
# proxy.  Oxyliquit tutorial forthcoming...
#
# This scheme is based on Apache's NameVirtualHost
# feature.  The following line should appear
# in your httpd.conf file:
#
#     NameVirtualHost *:80
#
# Next, add the following.
#
# You *could* put this directly in httpd.conf.
#
# But with large numbers of virtual hosts,
# it makes sense to have an include directory
# under your_apache_install/conf and add this
# to httpd.conf:
#
#    Include conf/vhosts/*
#
# or
#
#   Include conf/vhosts/foo.com
#   Include conf/vhosts/bar.com
#

<VirtualHost *:80>
 ServerName myhost.com
 ServerAlias www.myhost.com
 ServerAlias myalias.net
 ServerAlias www.myalias.net
 RewriteEngine On
 ProxyRequests off
 ProxyPass / http://127.0.0.1:9001/
 ProxyPassReverse / http://127.0.0.1:9001/
 ProxyPreserveHost on

# If your application exposes administrative URLs that
# you want to protect, then you can redirect to an ssl
# port on the server.

 RewriteRule ^/admin(.*) https://admin.myhost.com/admin$1 [L,R]
 RewriteRule ^/(.*) http://127.0.0.1:9001/$1 [L,P]

</VirtualHost>


#
#  If you want an SSL port for secure URLs for your app,
#  create an additional vhost
#
# Again, remember to add this somewhere before it:
#
#  NameVirtualHost *:443
#

<VirtualHost *:443>
  ServerName admin.myhost.com
  ServerAlias topsecret.myhost.com
  ProxyRequests off
  ProxyPass / http://127.0.0.1:9001/
  ProxyPassReverse / http://127.0.0.1:9001/
  ProxyPreserveHost on

  <Location />
     AuthName "Restricted Access"
     AuthType Basic
     Require user YoursTruly
     AuthUserFile /top/secret/path/htpasswd
  </Location>

  <Location /foo>
     AuthName "Restricted Access"
     AuthType Basic
     Require group SiteEditors
     AuthUserFile /top/secret/path/htpasswd
  </Location>

  SSLEngine on
  SSLCipherSuite ALL:!ADH:!EXPORT56:RC4 RSA: HIGH: MEDIUM: LOW: SSLv2: EXP: eNULL
  SSLCertificateFile /path-to-cert-files/ssl.crt/self_signed.cert
  SSLCertificateKeyFile /path-to-cert-files/ssl.key/self_signed.key
  SSLOptions  FakeBasicAuth  ExportCertData  CompatEnvVars  StrictRequire
</VirtualHost>

  • 1