Welcome! Log In Create A New Profile

Advanced

Re: alias vs root in regex location

Francis Daly
April 11, 2015 06:08AM
On Fri, Apr 10, 2015 at 07:09:43PM -0400, avi9526 wrote:

Hi there,

> Trying to serve nagios web GUI through nginx.

> location ~ "^/nagios/(.+?\.php)(/.*)?$"
> {
> alias "/usr/share/nagios3/htdocs/";
> try_files $1 $uri $uri/ /nagios/index.php;

> location ~* ^/cgi-bin/nagios3/(.+?\.cgi)$
> {
> alias "/usr/lib/cgi-bin/nagios3/";
> try_files $1 $uri $uri/ =404;

> it's seems to be working. If i change "alias" to "root" and uncomment
> "rewrite" directive for both php and cgi scripts it will work as well. So,
> what the difference?

http://nginx.org/r/root and http://nginx.org/r/alias.

Note that "alias" and "try_files" do have some unobvious interactions,
especially in a regex location. See http://trac.nginx.org/nginx/ticket/97
for some details.

Your configuration works because of your non-typical "try_files"
directive. I suspect that not all of the four arguments are ever used --
but it does depend on the incoming request, the files on the file system,
and how you want them to be matched together.

> And why most online manuals suggests to use "root"
> followed by rewrite?

I don't see that.

I see some suggesting root and rewrite; and some suggesting root; and
some suggesting alias.

I suspect that it depends on where things are installed.

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

alias vs root in regex location

avi9526 April 10, 2015 07:09PM

Re: alias vs root in regex location

Francis Daly April 11, 2015 06:08AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 188
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready