Apache Proxy Production Directives

8 December 2015 by admin

Where to place Directives

If your main Apache config file has granted

AllowOverride All

for your site directory, then you should place these directives before all other directives in:

$sitedir/.htaccess

If you can not use .htaccess, then the proxy directives should be placed in your main Apache config. If you are using a VirtualHost directive to configure your site, the directives should go inside of that VirtualHost directive. If you are not using a VirtualHost directive, then the proxy directives should be placed before any other RewriteRule directives you may have, or just at the end of the config file.

Required Modules

The following Apache modules are required:

  1. mod_rewrite
  2. mod_proxy
  3. mod_proxy_http

Production Directives

# BEGIN YAVLI
<IfModule mod_rewrite.c>
  <IfModule mod_proxy.c>
   <IfModule mod_proxy_http.c>
     RewriteEngine on
     RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteRule "(.*\.(jpg|jpeg|png|gif|js|css))$" "http://steg.yavli.com/$1" [NC,P]
   </IfModule>
 </IfModule>
</IfModule>
# END YAVLI

Note For WordPress Sites

If you are using WordPress, your .htaccess file probably has the following – or a similar – WordPress-specific configuration block:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Our configuration has to be placed above this WordPress block, otherwise Apache will ignore it.