Reverse proxy config

From Wiki
Jump to: navigation, search
<VirtualHost *:80>
ServerName frontend-1b834f.23.253.229.160.xip.io
ServerAlias www.frontend-1b834f.23.253.229.160.xip.io
SetEnvIf Request_URI "^/.*\.jpg$" dontlog
SetEnvIf Request_URI "^/.*\.png$" dontlog
SetEnvIf Request_URI "^/.*\.gif$" dontlog
RewriteEngine On
RewriteRule /(.*)\.(jpg|gif|png)$ http://backend-1b834f.23.253.229.160.xip.io:8001/$1.$2 [P]
#<IfModule mod_proxy.c>
#  ProxyPassMatch ^(.*\.gif)$ http://backend-1b834f.23.253.229.160.xip.io:8001/$1
#  ProxyPassMatch ^(.*\.jpg)$ http://backend-1b834f.23.253.229.160.xip.io:8001/$1
#  ProxyPassMatch ^(.*\.png)$ http://backend-1b834f.23.253.229.160.xip.io:8001/$1
#  ProxyPassReverse / http://backend-1b834f.23.253.229.160.xip.io:8001
#</IfModule>
DocumentRoot /var/www/vhosts/frontend-1b834f/htdocs
ErrorLog /var/www/vhosts/frontend-1b834f/logs/error.log
CustomLog /var/www/vhosts/frontend-1b834f/logs/access.log combined env=!dontlog
</VirtualHost>

<VirtualHost *:8001>
ServerName backend-1b834f.23.253.229.160.xip.io
ServerAlias www.backend-1b834f.23.253.229.160.xip.io
DocumentRoot /var/www/vhosts/backend-1b834f/htdocs
CustomLog /var/www/vhosts/backend-1b834f/logs/access.log combined env=!dontlog
<FilesMatch "(?<!\.jpg|\.gif|\.png)$"> 
Order Allow,Deny
Deny from all
</FilesMatch>
</VirtualHost>

viewvc directives:

<IfModule mod_proxy.c>
ProxyPass /viewvc http://cvs.example.com/viewvc
ProxyPass /viewvc-static http://cvs.example.com/viewvc-static
</IfModule>

Proxy site to external domain:

<IfModule mod_proxy.c>
ProxyPassMatch ^(/.*)$ http://www.domain2.com$1
</IfModule>

Mask domain to serve content from 2nd domain:

RewriteEngine On
RewriteRule /(.*)$ http://domain.com/dir/$1 [P]

Official docs available at http://httpd.apache.org/docs/2.2/mod/mod_proxy.html