Welcome! Log In Create A New Profile

Advanced

Advice on dynamic subdomains configuration

Posted by pockata 
Advice on dynamic subdomains configuration
May 06, 2012 06:16AM
HI, i am using nginx to serve content from from subdomains, dynamically created as directories.
I have two folders in my web path: "public" (where my main site's files are located) and "subdomains".
The "subdomains" directory contains directories which are accessed via the subdomains.
e.g. subdomains/test/index.html is accessed when opening http://test.domain.com/index.html

Here is the relevant part of my conf file.

server {
...
set $myroot /home/user/web/public;
set $subdomains /home/user/web/subdomains;
if ($host ~* (.*)\.domain\.com$) { set $myroot $subdomains/$1; }
root $myroot;
location / { .... }
....
}

My question is this: Is this configuration dangereous because of the "if" use or is it safe?
I read all sorts of articles saying alot of different things. Some of them say that the "if" statement is bad only in a "location" context, others say it's always bad. I am really confused.
Please share your oppinions. Thanks !
Sorry, only registered users may post in this forum.

Click here to login

Online Users

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