# Sub-domains through different /etc/nginx/sites-enabled entries?

**URL:** <https://www.ruby-forum.com/t/sub-domains-through-different-etc-nginx-sites-enabled-entries/221885>\
**Category:** NGINX\
**Created:** [August 3, 2012, 10:02am UTC](https://www.ruby-forum.com/t/sub-domains-through-different-etc-nginx-sites-enabled-entries/221885 "2012-08-03T10:02:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [August 3, 2012, 10:02am UTC](https://www.ruby-forum.com/t/sub-domains-through-different-etc-nginx-sites-enabled-entries/221885/1 "2012-08-03T10:02:55Z")

</div>

Hello,

I’m refining here my question that remained unanswered under the topic  
“Distribution of requests to multiple lxc containers” …

Is it possible to distribute sub-domains of one domain through  
independent  
files/links in sites-available/sites-enables entries? I’d love to have  
the  
flexibility to enable/disable services running at different sub-domains  
without having to edit a (joined) file/link, but with the two entries  
below  
requests to “[mail.MYDOMAIN.org](http://mail.MYDOMAIN.org)” (trying to reach a lxc  
container (supposedly) proxied by the second entry) end up returning an  
error produced by the the first one.

Thanks for any pointers on what I might be doing wrong or whether I have  
to  
resort to one sites-available/enabled file.

Joh

> server {  
> listen 443;  
> server\_name [MYDOMAIN.org](http://MYDOMAIN.org) [HOSTING.net](http://HOSTING.net);  
> client\_max\_body\_size 40M;  
> # SSL is using CACert credentials  
> ssl on;  
> ssl\_certificate /etc/ssl/private/cacert.MYDOMAIN.org.pem;  
> ssl\_certificate\_key  
> /etc/ssl/private/cacert.MYDOMAIN.org\_privatkey.pem;  
> ssl\_session\_timeout 5m;  
> ssl\_protocols SSLv3 TLSv1;  
> ssl\_ciphers ALL:!ADH:!EXPORT56:!LOW:RC4+RSA:+HIGH:+MEDIUM:+SSLv3:  
> +EXP;  
> ssl\_prefer\_server\_ciphers on;  
> # Proxy the “[plone.MYDOMAIN.org](http://plone.MYDOMAIN.org)” lxc container  
> location / {  
> proxy\_pass  
> [http://10.10.10.2:8080/VirtualHostBase/https/HOSTING.net:443/MYDOMAINPlone/VirtualHostRoot/](http://10.10.10.2:8080/VirtualHostBase/https/HOSTING.net:443/MYDOMAINPlone/VirtualHostRoot/);  
> }  
> }

> server {  
> listen 443;  
> server\_name [mail.MYDOMAIN.org](http://mail.MYDOMAIN.org) [mail.HOSTING.net](http://mail.HOSTING.net);  
> client\_max\_body\_size 40M;  
> # SSL is using CACert credentials  
> ssl on;  
> ssl\_certificate /etc/ssl/private/cacert.MYDOMAIN.org.pem;  
> ssl\_certificate\_key  
> /etc/ssl/private/cacert.MYDOMAIN.org\_privatkey.pem;  
> ssl\_session\_timeout 5m;  
> ssl\_protocols SSLv3 TLSv1;  
> ssl\_ciphers ALL:!ADH:!EXPORT56:!LOW:RC4+RSA:+HIGH:+MEDIUM:+SSLv3:  
> +EXP;

---

<div class="post-metadata">

**Author:** ![Johannes\_Graumann](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@Johannes\_Graumann](https://www.ruby-forum.com/u/Johannes_Graumann)\
**Post date:** [August 3, 2012, 11:27am UTC](https://www.ruby-forum.com/t/sub-domains-through-different-etc-nginx-sites-enabled-entries/221885/2 "2012-08-03T11:27:06Z")

</div>

Johannes,

Is this what you are asking for?

# cat /etc/nginx/sites-enabled/site1

server {  
listen 80;  
server\_name [subdomain1.domain.com](http://subdomain1.domain.com)  
# config…  
}

# cat /etc/nginx/sites-enabled/site2

server {  
listen 80;  
server\_name [subdomain2.domain.com](http://subdomain2.domain.com)  
# config…  
}

…

# cat /etc/nginx/sites-enabled/siteN

server {  
listen 80;  
server\_name [subdomainN.domain.com](http://subdomainN.domain.com)  
# config…  
}

where:

/etc/nginx/sites-enabled/siteX

is a symlink to:

/etc/nginx/sites-available/siteX

Yes, this is possible 🙂

–  
Unai R.  
Cofounder  
LeanWired LLP  
[www.leanservers.com](http://www.leanservers.com)  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
