Is it possible using multiple directive on different root location? (Without Symlinks)

Hi, basic on Pitfalls and Common Mistakes | NGINX, I want to ask my directives
like
this :

This directive on balancer :

And then, this directives on backend :

I want to give a subdomain like this NameBright - Coming Soon,
and
/cdn will have a root dir to /home/antituhan/public_html/, and now I use
symlink to static :

So, I can access the domain like this NameBright - Coming Soon

If I don’t use symlink, is it possible to add another directive on
nginx?
And if is not possible, is it safe for nginx directive? Thank you

On Tue, 2012-05-01 at 02:36 -0700, antituhan wrote:

Hi, basic on Pitfalls and Common Mistakes | NGINX, I want to ask my directives like
this :

This directive on balancer :

And then, this directives on backend :

I fear you may have over-simplified your examples.

Cliff

So, what should I do Cliff ? Which directive should I use for it ?

On 01/05/2012 19:58, antituhan wrote:

So, what should I do Cliff ? Which directive should I use for it ?
how about regex match for locations?
nginx Info Page

Eliezer C.
https://www1.ngtech.co.il
IT consulting for Nonprofit organizations
eliezer ngtech.co.il

Perhaps an alias?

location /cdn/ {
alias /home/antituhan/public_html/;
}

Cliff

On Tue, May 01, 2012 at 09:21:13AM -0700, Cliff W. wrote:

On Tue, 2012-05-01 at 02:36 -0700, antituhan wrote:

Hi there,

this :

This directive on balancer :

And then, this directives on backend :

I think Cliff’s point is that the nabble.com interface that you are
using to post, seems to be corrupting what you post before sending it
to the nginx mailing list.

So anyone reading your message anywhere other than at nabble.com doesn’t
see any of the configuration that you intended to show.

For the benefit of the list archives (and having more people who might
be able to offer help), could you repeat your first post, but do
whatever
it takes to get it sent to the mailing list intact?

(That might involve some setting saying “this is plain text”, perhaps.)

f

Francis D. [email protected]

If using alias, what the root document directive? Becasue public_html is
outside the /home/antituhan/static. I’ve tried using alias
/home/antituhan/public_html but the nginx shows errors not found. Any
solution ?

Cliff W. wrote

On Tue, 2012-05-01 at 19:20 -0700, antituhan wrote:

If using alias, what the root document directive? Becasue public_html is
outside the /home/antituhan/static. I’ve tried using alias
/home/antituhan/public_html but the nginx shows errors not found. Any
solution ?

Pay attention to the slashes. /home/antituhan/static is not the same
as /home/antituhan/static/ for an alias.

If you could share your error log, it would be helpful.

The following works for me:

server {
listen localhost:80;

root /var/www/test;

location / {
    index index.html;
}

location /cdn/ {
    alias /var/www/static_html/;
}

}

index.html has and it shows up fine.

Regards,
Cliff

How about php directive cliff ? I still get errors, my full directive
like
this http://fpaste.org/TOW3/

And i have a index.php on /home/antituhan/public_html to be triggered by
another upstream outsite with
NameBright - Coming Soon and it says not
found. Is my .php directive wrong ?

Thank you

Cliff W. wrote

So, how to solve the fastcgi php path with $document_root directive? By
using
fix path like /home/antituhan/static + multiple fastcgi directive or any
directive to solve this issue?

Francis D. wrote

On Thu, May 10, 2012 at 09:58:10PM -0700, antituhan wrote:

Hi there,

So, how to solve the fastcgi php path with $document_root directive? By using
fix path like /home/antituhan/static + multiple fastcgi directive or any
directive to solve this issue?

If this part:

Probably you’ll want to look at nesting a php location inside the /cdnize/
one. And then moving the current php location to be inside the / one.

So you will probably need to have two or more locations that handle php,
which each use a fastcgi_pass directive.

is unclear, please say so.

After that:

  • what did you do?
  • what did you see?
  • what did you expect to see?

(As in: show your config; and show one url that you tested that did not
respond as you wanted.)

f

Francis D. [email protected]

On Thu, May 03, 2012 at 05:59:54AM -0700, antituhan wrote:

Hi there,

How about php directive cliff ? I still get errors, my full directive like
this http://fpaste.org/TOW3/

The important part here is that your top-level location{} directives are

location /
location /cdnize/
location ~ .php$

Each request will be handled by exactly one of those blocks.

And i have a index.php on /home/antituhan/public_html to be triggered by
another upstream outsite with
NameBright - Coming Soon and it says not
found. Is my .php directive wrong ?

The request for /cdnize/index.php would be handled by the “location ~
.php$” block.

In there, you have

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

and $document_root is “root”, which is inherited from the

root /home/antituhan/static;

directive at server level. So this request ends up (with the fastcgi
server) looking for the file /home/antituhan/static/cdnize/index.php,
which is presumably not what you want.

Probably you’ll want to look at nesting a php location inside the
/cdnize/
one. And then moving the current php location to be inside the / one.

So you will probably need to have two or more locations that handle php,
which each use a fastcgi_pass directive.

I’m sure there are recent examples of this set-up on the mailing list.

Good luck with it,

f

Francis D. [email protected]

On Tue, Nov 27, 2012 at 04:08:21AM -0800, antituhan wrote:

Hi there,

Change $document_root$fastcgi_script_name into $document_root$1, but I still
got 403 Forbidden when access NameBright - Coming Soon

What file do you want the fastcgi server to process when you request
NameBright - Coming Soon?

If it is /something/test/tehboto1.php, then put “root /something” inside
the location{} block and use $document_root$fastcgi_script_name.

If it isn’t, then you’ll need to build what it is in some other way.

f

Francis D. [email protected]

Hi F,

Yup, i want the fastcgi server to process the .php files. I’ve tried to
set
like this

While I access NameBright - Coming Soon the error
log
shows that tehbotol.php can’t found on /something/test/tehbotol.php

Francis D. wrote

NameBright - Coming Soon?

If it is /something/test/tehboto1.php, then put “root /something” inside
the location{} block and use $document_root$fastcgi_script_name.

If it isn’t, then you’ll need to build what it is in some other way.

f

Francis D.

francis@


nginx mailing list

nginx@

On Tue, Dec 04, 2012 at 08:10:37AM -0800, antituhan wrote:

While I access NameBright - Coming Soon the error log
shows that tehbotol.php can’t found on /something/test/tehbotol.php

What file do you want the fastcgi server to process when you request
NameBright - Coming Soon?

f

Francis D. [email protected]

Hello f,

Sorry for longtime no reply to this thread, because of another project.
I
want to continue this case, and I try the directive like this
http://fpaste.org/n8FS/

I got the reference from here

Change $document_root$fastcgi_script_name into $document_root$1, but I
still
got 403 Forbidden when access
http://static.antituhan.com/test/tehbotol.php

tehbotol.php content is :

Francis D. wrote


Francis D.

francis@


nginx mailing list

nginx@