Welcome! Log In Create A New Profile

Advanced

How to do global settings affecting all virtual hosts

Posted by qian 
How to do global settings affecting all virtual hosts
May 10, 2009 11:09AM
I am coming from Apache, very new to Nginx. A lot of my thinkings are still Apache-style. I know Nginx is different. So, how to specify global settings?

For example, to deny access to .ht files. I don't want to write

location ~ /\.ht {
deny all;
}

in every virtual hosts. If I forget to the settings in some hosts, these hosts are at risk.

Is there an more bomb proof way to achieve that? Thanks
Re: How to do global settings affecting all virtual hosts
May 10, 2009 05:57PM
No.

But what risk is there? You won't be using .htaccess files with nginx so there is no need to have them.

--
Jim Ohlstein
Re: How to do global settings affecting all virtual hosts
May 11, 2009 11:05AM
Hi, Jim,

I just use .htaccess as an example. Basically, I find it is hard to configure globally for all virutal hosts at one place because location must be inside the server directive.

Another example is - apache alias equivalent - in apache, I can just add line

alias /phpMyAdmin /path/to/phpMyAdmin

then http://all-virtual-hosts/phpMyAdmin is available to all hosts. In Nginx, I have to add as many times as the virtual hosts?

BTW,
location ~ /\.ht {
deny all;
}
is not my idea. It comes with nginx default. I think it is useful because
[quote]# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one[/quote]
Re: How to do global settings affecting all virtual hosts
May 11, 2009 12:56PM
I understand that it is in the sample config file. But you were worried about hosts being "at risk". I'm still not sure what you meant.

Nginx is not Apache and there are things that are done differently.

What many people do is to create a file and add a line to include it in every server block. In it you can have whatever you think needs to be in *every* virtual host and then one line in the server block and it's there.

--
Jim Ohlstein
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 160
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