Add_before_body

Hey!

I’m trying to use the add_before_body in nginx.comf,

add_before_body
\subsites\dropletlocal\library\global\func-global.class.php;

After I add it all the sites display a “No input file specified.”.

If I use:

add_before_body \subsites\dropletlocal\library\global\test.html;

The file gets included fine, and displays the HTML.

Posted at Nginx Forum:

On Wed, Mar 04, 2015 at 11:33:50AM -0500, neophyte wrote:

Hi there,

I’m trying to use the add_before_body in nginx.comf,

The documentation is at Module ngx_http_addition_module

add_before_body
\subsites\dropletlocal\library\global\func-global.class.php;

After I add it all the sites display a “No input file specified.”.

What does your configuration say about how to handle that request?

(You may find it works better if you use / not .)

f

Francis D. [email protected]

I’ve swapped to using /.
https://gist.github.com/anonymous/423cbe11f91e4d342dd6 - My comf.

Posted at Nginx Forum:

I can’t manually add it to each file because I use a include *.comf, I
just
need Nginx to perform add_before_body without it being in each server
block.

Posted at Nginx Forum:

Let me clear that up,

I need add_before_body
/subsites/dropletlocal/library/global/func-global.class.php;
to work on every site that is hosted, I can’t manually add every block
or
I’d have to do it for over 500 websites, intern taking too long and too
much
downtime, also I can’t because the directory would be different for each
server because of file indention of websites with specific settings.

Posted at Nginx Forum:

On Wed, Mar 04, 2015 at 05:30:22PM -0500, neophyte wrote:

Hi there,

I can’t manually add it to each file because I use a include *.comf, I just
need Nginx to perform add_before_body without it being in each server block.

I’m afraid that I have failed to understand what you want to configure
nginx to do.

So I will describe what you have configured nginx to do, and perhaps
you or someone will be able to see where “what you want” and “what you
have” differ.

When you request http://localhost/index.html, nginx will send the
content
of the file /usr/local/nginx/htdocs/subsites/dropletlocal/index.html,
prefixed by whatever your fastcgi server
returns when it is asked to process the file
/usr/local/nginx/htdocs/subsites/dropletlocal/subsites/dropletlocal/library/global/func-global.class.php.

When you request http://one.es.vc/index.html, nginx will send the
content
of the file /usr/local/nginx/htdocs/subsites/one/index.html prefixed by
whatever your fastcgi server returns when it is asked to process the
file
/usr/local/nginx/htdocs/subsites/one/subsites/dropletlocal/library/global/func-global.class.php.

Your 500 included .conf files already have many lines the same in
them. It is not clear to me why you can’t add one more “include
the_add_before_body_bit;” line to each. But I’m sure you have your
reasons.

Good luck with it,

f

Francis D. [email protected]

Even when I add_before_body on every individual server it still gives me
“Input file not specified”

Posted at Nginx Forum:

worker_processes 8;
events {
worker_connections 1024;
}
http {
gzip off;
root htdocs;
add_before_body
subsites/dropletlocal/library/global/func-global.class.php;
#DOESN’T
add_before_body subsites/dropletlocal/library/global/test.html;
#WORKS
include mime.types;
include web-hosting/*.conf;
}

I don’t understand how come html works fine but php wont?

Posted at Nginx Forum:

On Wed, Mar 04, 2015 at 04:51:43PM -0500, neophyte wrote:

Hi there,

I’ve swapped to using /.
https://gist.github.com/anonymous/423cbe11f91e4d342dd6 - My comf.

That is:

“”"
http {
add_before_body
/subsites/dropletlocal/library/global/func-global.class.php;
server {
server_name localhost;
location / {
root htdocs/subsites/dropletlocal;
index proxy.php;
}
location ~ .php$ {
root htdocs/subsites/dropletlocal;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
include fastcgi_params;
}
}
server {
server_name .es.vc;
location / {
root htdocs/subsites/
;
index index.php;
}
location ~ .php$ {
root htdocs/subsites/***;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
“”"

more or less.

So, what do you want nginx to do with your add_before_body subrequest?

As in: which file on the filesystem do you want the fastcgi processor
to read?

Possibly you will want to add something like

location = /subsites/dropletlocal/library/global/func-global.class.php
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME the_file_that_you_care_about;
include fastcgi_params;
}

to each server block; possibly something else will work.

Good luck with it,

f

Francis D. [email protected]

neophyte Wrote:

Even when I add_before_body on every individual server it still gives
me “Input file not specified”

This message is a PHP message, you have a php location block somewhere
trying to run a php script and failing (script not found).

Posted at Nginx Forum: