# Include directive not allowed in upstream?

**URL:** <https://www.ruby-forum.com/t/include-directive-not-allowed-in-upstream/207819>\
**Category:** NGINX\
**Created:** [June 3, 2011, 1:18pm UTC](https://www.ruby-forum.com/t/include-directive-not-allowed-in-upstream/207819 "2011-06-03T13:18:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [June 3, 2011, 1:18pm UTC](https://www.ruby-forum.com/t/include-directive-not-allowed-in-upstream/207819/1 "2011-06-03T13:18:57Z")

</div>

We have a number of upstream blocks for different vhosts / processes but  
a number of them make use of the same backend nodes so I wanted to  
simply out upsteam declarations by using includes. On doing so we get  
the follow error:-  
nginx: [emerg] “include” directive is not allowed here in  
/usr/local/etc/nginx/nginx.conf:61

Seems like include is not possible in an upstream block. I can’t think  
of a logical reason for this, any ideas?

Seems this would be quite a nice feature to add.

Posted at Nginx Forum:

> **[include directive not allowed in upstream?](https://forum.nginx.org/read.php?2,203585,203585#msg-203585)**
>
> We have a number of upstream blocks for different vhosts / processes but a number of them make use of the same backend nodes so I wanted to simply out upsteam declarations by using includes. On doing so we get the follow error:- nginx: \[emerg\]...

---

<div class="post-metadata">

**Author:** ![steveh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5fc32e/32.png) [@steveh](https://www.ruby-forum.com/u/steveh)\
**Post date:** [June 3, 2011, 7:26pm UTC](https://www.ruby-forum.com/t/include-directive-not-allowed-in-upstream/207819/2 "2011-06-03T19:26:26Z")

</div>

I’m curious, do you base that logical reason on a “the code should allow  
this” or “it would be nice to have”? There’s really no way to use  
include in an upstream directive. You should make sure your vhosts use  
the same upstream as opposed to defining multiple upstreams with  
identical servers.

Posted at Nginx Forum:

> **[Re: include directive not allowed in upstream?](https://forum.nginx.org/read.php?2,203585,203692#msg-203692)**
>
> We have a number of upstream blocks for different vhosts / processes but a number of them make use of the same backend nodes so I wanted to simply out upsteam declarations by using includes. On doing so we get the follow error:- nginx: \[emerg\]...

---

<div class="post-metadata">

**Author:** ![steveh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5fc32e/32.png) [@steveh](https://www.ruby-forum.com/u/steveh)\
**Post date:** [June 4, 2011, 12:13am UTC](https://www.ruby-forum.com/t/include-directive-not-allowed-in-upstream/207819/3 "2011-06-04T00:13:35Z")

</div>

My question is more, is there any reason why it can’t support this? I  
can’t think of any reason why this shouldn’t be possible, its really  
only a block in my mind.

You say there really no way to use include in upstream, but why is this?  
I know it can’t currently but why?

Its not a case of the vhosts using the same upstream but more multiple  
machines including blocks of hosts within to support their task, would  
make what were trying to do cleaner and easier to mange.

Posted at Nginx Forum:

> **[Re: include directive not allowed in upstream?](https://forum.nginx.org/read.php?2,203585,203754#msg-203754)**
>
> We have a number of upstream blocks for different vhosts / processes but a number of them make use of the same backend nodes so I wanted to simply out upsteam declarations by using includes. On doing so we get the follow error:- nginx: \[emerg\]...
