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

Posted by antituhan (Guest)
on 2012-05-01 11:36
(Received via mailing list)
Hi, basic on http://wiki.nginx.org/Pitfalls, 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 http://static.antituhan.com/cdn, 
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 http://static.antituhan.com/cdn

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
Posted by Cliff Wells (Guest)
on 2012-05-01 18:21
(Received via mailing list)
On Tue, 2012-05-01 at 02:36 -0700, antituhan wrote:
> Hi, basic on http://wiki.nginx.org/Pitfalls, 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
Posted by antituhan (Guest)
on 2012-05-01 18:58
(Received via mailing list)
So, what should I do Cliff ? Which directive should I use for it ?
Posted by Eliezer Croitoru (Guest)
on 2012-05-01 19:01
(Received via mailing list)
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?
> http://mailman.nginx.org/mailman/listinfo/nginx
--
Eliezer Croitoru
https://www1.ngtech.co.il
IT consulting for Nonprofit organizations
eliezer <at> ngtech.co.il
Posted by Francis Daly (Guest)
on 2012-05-01 19:53
(Received via mailing list)
On Tue, May 01, 2012 at 09:21:13AM -0700, Cliff Wells 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 Daly        francis@daoine.org
Posted by Cliff Wells (Guest)
on 2012-05-01 20:29
(Received via mailing list)
Perhaps an alias?

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

Cliff
Posted by antituhan (Guest)
on 2012-05-02 04:20
(Received via mailing list)
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 Wells wrote
Posted by Cliff Wells (Guest)
on 2012-05-02 06:57
(Received via mailing list)
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 <img src="/cdn/1.jpg" /> and it shows up fine.

Regards,
Cliff
Posted by antituhan (Guest)
on 2012-05-03 15:00
(Received via mailing list)
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
http://static.antituhan.com/cdnize/index.php?q=datahere and it says not
found. Is my .php directive wrong ?

Thank you


Cliff Wells wrote
Posted by Francis Daly (Guest)
on 2012-05-04 00:43
(Received via mailing list)
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
> http://static.antituhan.com/cdnize/index.php?q=datahere 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 Daly        francis@daoine.org
Posted by antituhan (Guest)
on 2012-05-11 06:58
(Received via mailing list)
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 Daly wrote
Posted by Francis Daly (Guest)
on 2012-05-11 10:04
(Received via mailing list)
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 Daly        francis@daoine.org
Posted by antituhan (Guest)
on 2012-11-27 13:09
(Received via mailing list)
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
http://serverfault.com/questions/415538/nginx-alia...

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
Posted by Francis Daly (Guest)
on 2012-11-30 23:39
(Received via mailing list)
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 http://static.antituhan.com/test/tehbotol.php

What file do you want the fastcgi server to process when you request
http://static.antituhan.com/test/tehbotol.php?

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 Daly        francis@daoine.org
Posted by antituhan (Guest)
on 2012-12-04 17:11
(Received via mailing list)
Hi F,

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



While I access http://static.antituhan.com/test/tehbotol.php the error 
log
shows that tehbotol.php can't found on /something/test/tehbotol.php


Francis Daly wrote
> http://static.antituhan.com/test/tehbotol.php?
>
> 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 Daly

> francis@

>
> _______________________________________________
> nginx mailing list

> nginx@
Posted by Francis Daly (Guest)
on 2012-12-04 18:45
(Received via mailing list)
On Tue, Dec 04, 2012 at 08:10:37AM -0800, antituhan wrote:

> While I access http://static.antituhan.com/test/tehbotol.php 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
http://static.antituhan.com/test/tehbotol.php?

  f
--
Francis Daly        francis@daoine.org
Posted by antituhan (Guest)
on 2012-12-06 03:12
(Received via mailing list)
tehbotol.php content is :




Francis Daly wrote
> --
> Francis Daly

> francis@

>
> _______________________________________________
> nginx mailing list

> nginx@
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.