Personal tools
You are here: Home Documentation How-Tos Use Apache HTTP server with Grok (on Debian Sid)

Use Apache HTTP server with Grok (on Debian Sid)

This How-to applies to: Any version.
This How-to is intended for: Any audience.

This Grok How-To gives a step-by-step explanation of how to install and configure Apache HTTP server version 2.2 on Debian Sid to serve Grok Web Applications using the mod_rewrite method.

Apache on Debian Sid - Using Apache HTTP server with our Grok web application

Question: Why does one want to use Apache to serve our Grok web application?

Answer: There are multiple possible reasons.

  • A Grok specific reason is that you cannot currently customise the base URL of Grok apps and serve them from the root server directory “/ ”.
  • Your website requires more than one framework or language from the same server. [1]
  • Zope's Zserver is not as robust as Apache. [2]
  • Zope's SSL is not as robust as Apache's. [2]
  • Apache HTTP server uses caching to speed up requests. [2]

There are three methods available for combining Apache and Grok:

  1. Mod_rewrite
  2. ProxyPass
  3. cgi

This how-to deals only with the mod_rewrite method as the other two are impractical. [1,2]

Steps involved:

  1. Install Apache
  2. Configure Apache

No configuration of Zope or Grok should be required! Zope uses something called virtual hosting to greatly simplify this procedure for us. [3] It works by having Apache request a URL which passes to Zope any configuration it needs in order to serve us our Grok application the way we want it.

Step One: Apache Installation

The first step is to install the Apache HTTP server, thankfully Debian makes this easy:

apt-get install apache2

Debian then does all the work and the important directories at the end of the installation are:

/etc/apache2 – for configuration

/var/log/apache2 – For logs

Step Two: Apache Configuration

The Debian package comes pre-configured to a certain extent so be sure to familiarize yourself with this in the /etc/apache2 directory at some point in the future. The Apache2 package also creates for you an empty file /etc/apache2/httpd.conf which is where you can add all the custom configuration you want for your apache server.

Useful syntax [4]:

  • # - comment
  • \ - line continuation

Here is a copy of my httpd.conf file:

LoadModule rewrite_module /usr/lib/apache2/modules/
LoadModule proxy_module /usr/lib/apache2/modules/
LoadModule proxy_http_module /usr/lib/apache2/modules/

ProxyRequests off

<VirtualHost *>
RewriteEngine On
RewriteLog "/var/log/apache2/rewrite.log"
RewriteLogLevel 1
RewriteRule ^(/?.*) \
http://localhost:8080/grokapp/$1 \

It is important to point out that Apache will not reload it's configuration files until it is restarted, this can be accomplished with the command 'Apache2ctl graceful'. [5]

These few lines of configuration are all that's required to set up apache serve your Grok application.

Understanding httpd.conf

Lines 1-3 Load the necessary Apache modules.

ProxyRequests off – this command is in the interest of safety to prevent your HTTP server from turning into an open proxy if you misconfigure it.

ServerName is a variable that's supposed to be declared both inside and outside the VirtualHost declaration.

The VirtualHost statement is used to compartmentalize Apache configuration, see the main docs. [6]

RewriteEngine On – turns on mod_rewrite.

RewriteLog “/var/log/apache2/rewrite.log” - makes mod_rewrite log it's activities consistent with Debian practice.

RewriteLogLevel – Choose 0-9 for how much gets logged. Start with 9 until everything is working then switch to your desired production level probably zero or one.

Configuring mod_rewrite

RewriteRule – This configuration takes two arguments in the form of Perl regular expression statements. [7,8]

The first regex statement a pattern that determines if mod_rewrite will process a URL, the second regex statement is a pattern that specifies how the URL will be processed.

In this particular case there is a third optional argument '[P,L]' which passes two options to mod_rewrite which force it to proxy and make this the last processing rule if applied.

You can have several RewriteRule statements and they are processed in the order they are found in the config file. Please refer to mod_rewrite docs for more info. [9]

The RewriteRule required will be different but similar for every grok user. If you need help with your RewriteRule there is a useful utility that will write it for you called the witch. [10]

The only problem with the RewriteRule witch is that she is written for zope2. Grok is based on zope3 and zope3 virtual hosting syntax has changed slightly so you will have to modify the second argument to look like it does in my sample configuration. [3]

Once Apache is configured, you're done. Everything in Grok should work automatically. In my case I can now access my Grok application which is being served by Zserver at through Apache by going to

If you need to troubleshoot, remember the apache logs are located in /var/log/apache2/

Good Luck!



Creative Commons License

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.

see also:

Grok, Virtual Hosting and Nginx
Configuring the super fast and lightweight Nginx HTTP server to support virtual hosting.