Welcome! Log In Create A New Profile

Advanced

Re: Dynamic Subdomain Configuration

Edho Arief
February 20, 2012 02:42PM
On Tue, Feb 21, 2012 at 2:28 AM, justin <nginx-forum@nginx.us> wrote:
> Hello,
>
> We provide a subdomain for each user, for example:
>
>     paul.ourdomain.com
>     jay.ourdomain.com
>     bob.ourdomain.com
>     xxxxx.ourdomain.com
>
> Currently, I am doing this manually by adding another config in
> /etc/nginx/conf.d for each subdomain. A typical conf looks like:
>
> server {
>  listen 80;
>
>  server_name paul.ourdomain.com;
>
>  root /srv/www/users/paul/wp;
>
>  index index.php;
>
>  access_log /var/log/nginx/vhosts/paul.access.log;
>  error_log /var/log/nginx/vhosts/paul.error.log;
>
>  include /etc/nginx/excludes.conf;
>  include /etc/nginx/wordpress.conf;
>  include /etc/nginx/expires.conf;
> }
>
> Is there I way I can abstract this, and prevent creating a configuration
> for each subdomain? I was reading something about map, but don't fully
> understand it.
>

Probably something like this:

map $host $username {
some.domain.com usera;
another.one.net userb;
}

server {
root /srv/www/users/$username/wp;
access_log /var/log/nginx/vhosts/$username.access.log;
...
}

Or this (without map):

server {
server_name ~^(?<username>.+)\.domain\.com$;
root /srv/www/users/$username/wp;
...
}

--
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

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

Dynamic Subdomain Configuration

Anonymous User February 20, 2012 02:28PM

Re: Dynamic Subdomain Configuration

Edho Arief February 20, 2012 02:42PM

Re: Dynamic Subdomain Configuration

Anonymous User February 20, 2012 02:55PM

Re: Dynamic Subdomain Configuration

Maxim Dounin February 20, 2012 04:16PM

Re: Dynamic Subdomain Configuration

Anonymous User February 20, 2012 06:45PM

Re: Dynamic Subdomain Configuration

Anonymous User February 20, 2012 07:18PM

Re: Dynamic Subdomain Configuration

Anonymous User February 20, 2012 08:28PM

Re: Dynamic Subdomain Configuration

Anonymous User February 20, 2012 08:40PM

Re: Dynamic Subdomain Configuration

Edho Arief February 20, 2012 08:12PM

Re: Dynamic Subdomain Configuration

Edho Arief February 20, 2012 08:34PM

Re: Dynamic Subdomain Configuration

Edho Arief February 20, 2012 08:54PM

Re: Dynamic Subdomain Configuration

Anonymous User February 21, 2012 01:46PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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