Apache as proxy

HTTP proxy (caching etc)

f apache.conf


Listen 8124
NameVirtualHost *:8124


<VirtualHost *:8124>
	ServerName proxy.foobar
	TransferLog /var/log/apache2/proxy-access.log
        ErrorLog /var/log/apache2/proxy-error.log

	<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteLog /var/log/apache2/rewrite.log
	RewriteLogLevel 9

	# Only rewrite requests that don't already have a Via: header
	# If there is a possibility of this proxy being in a chain
	# then you'll have to test the Via hostname value as well using something like this
	RewriteCond %{HTTP:Via} !.*proxy.foobar.*
	RewriteCond %{HTTP:Via} ^$

	# Alter the GET /... to GET http://host/... so it is treated as
	# a proxy request, and then forward it to mod_proxy immediately
	RewriteRule ^/(.*) http://%{HTTP_HOST}$1 [P]
	#RewriteRule (.*)	[P]
	</IfModule>

	<IfModule mod_proxy.c>
		ProxyRequests On
		ProxyVia On
		# don't proxy for LAN addresses
		NoProxy localhost 10.0.0.0/8 127.0.0.0/8 192.168.0.0/16
		# default LAN domain for use where FQDNs aren't being used
		ProxyBadHeader Ignore
		ProxyStatus On
		ProxyPreserveHost On

		# limit connections to LAN clients
		<Proxy *>
			Order Deny,Allow
			Deny from all
			Allow from 10.0.0.0/8
			Allow from 127.0.0.0/8
			Allow from 192.168.0.0/16
		</Proxy>
	</IfModule>
</VirtualHost>