Addition Module

Hello!

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/ {
            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
user.domain.com 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:

302 Found

302 Found


nginx/0.6.29 Body of the html page

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

What am I doing wrong? :slight_smile:

TIA!

Tony

    }
}

Forgive the reply to myself but I found the source of the problem. I
wondered if the .internal was being prepended and accidentally put a
symlink
to itself (infinite loop) in the /www/html and it threw an error. Sure
enough, it was looking in /www/html/.internal/ - I could not get any
logging
to show this before.

So now I see my code being included but it is not what I want. I am
getting:

Body of page

I want the included code to appear immediately after the opening body
tag
(in-line html insertion). I’ve googled around a fair bit but have not
found
anything in the results pointing to such an ability. I cannot depend on
a
consistent set of options in the body tag since the html pages are user
created (not by us). I was hoping that the Addition Module truly was
like
mod_layout in the comparison matrix, but it is not.

Does anyone have any pointers/suggestions?

TIA!

Tony