Addition Module


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.
configuration is as follows:

(cutting out unneeded portions)

server {

set $vhost ‘—’;
if ($http_host ~ ^(.)(.)(.)(.+) {
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:

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:




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
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
to show this before.

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

Body of page

I want the included code to appear immediately after the opening body
(in-line html insertion). I’ve googled around a fair bit but have not
anything in the results pointing to such an ability. I cannot depend on
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
mod_layout in the comparison matrix, but it is not.

Does anyone have any pointers/suggestions?



This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs