Addition Module

Tony Holmes atholmes at
Tue Apr 1 16:38:45 MSD 2008


I am having difficulty getting the Addition Module to function correctly. I
simply want to add a chunk of html to the top of every html file served. My
configuration is as follows:

(cutting out unneeded portions)

    server {
        set $vhost '---';
        if ($http_host ~ ^(.)(.)(.)(.+)\.domain\.com) {
                set $vhost $1$2$3$4;
                set $vdir $1/$2/$3/$vhost;

        if ($vhost = '---') {
                return 404;

        location / {
                add_before_body         /.internal/banner.html;
                root                    /www/users/$vdir;
                index                   index.html index.htm;

        location /.internal/ {
                root    /www/html;

So I use the host as the username and do a 3 character hash (testing for
invalid username format). The homedirs are rooted at /www/users. Hence is rooted at /www/users/u/s/e/user.

The file for the banner is located in /www/html/banner.html so I use the
/.internal/ location to set the root. Then end result is this:

<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>
Body of the html page

Instead of the contents of banner.html, I am getting a 302 page.

What am I doing wrong? :)


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list