# Is it possible to use a remote file to store servernames? server\_name $somevariable-file?

**URL:** <https://www.ruby-forum.com/t/is-it-possible-to-use-a-remote-file-to-store-servernames-server-name-somevariable-file/214310>\
**Category:** NGINX\
**Created:** [November 28, 2011, 11:45am UTC](https://www.ruby-forum.com/t/is-it-possible-to-use-a-remote-file-to-store-servernames-server-name-somevariable-file/214310 "2011-11-28T11:45:10Z")\
**Posts on this page:** 4\
**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:** [November 28, 2011, 11:45am UTC](https://www.ruby-forum.com/t/is-it-possible-to-use-a-remote-file-to-store-servernames-server-name-somevariable-file/214310/1 "2011-11-28T11:45:10Z")

</div>

I need to add a lot of sub-domains to a configuration file as users  
register on our website our script needs to add the sub-domain. Is it  
possible to use a variable or function in the config file so it loads a  
remote file which has sub-domains listed one per line? It would be  
easier for our developers to add a sub-domain one per line into a file.  
Then trying to add them into the configuration file directly.

server\_name $some-function;

Posted at Nginx Forum:

> **[Is it possible to use a remote file to store servernames? server\_name...](https://forum.nginx.org/read.php?2,219193,219193#msg-219193)**
>
> I need to add a lot of sub-domains to a configuration file as users register on our website our script needs to add the sub-domain. Is it possible to use a variable or function in the config file so it loads a remote file which has sub-domains listed...

---

<div class="post-metadata">

**Author:** ![anagio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/977dab/32.png) [@anagio](https://www.ruby-forum.com/u/anagio)\
**Post date:** [November 28, 2011, 12:46pm UTC](https://www.ruby-forum.com/t/is-it-possible-to-use-a-remote-file-to-store-servernames-server-name-somevariable-file/214310/2 "2011-11-28T12:46:23Z")

</div>

On Mon, Nov 28, 2011 at 05:44:32AM -0500, anagio wrote:

> I need to add a lot of sub-domains to a configuration file as users  
> register on our website our script needs to add the sub-domain. Is it  
> possible to use a variable or function in the config file so it loads a  
> remote file which has sub-domains listed one per line? It would be  
> easier for our developers to add a sub-domain one per line into a file.  
> Then trying to add them into the configuration file directly.
> 
> server\_name $some-function;

> **[Core functionality](http://nginx.org/en/docs/ngx_core_module.html#include)**
>
> Includes another file, or files matching the specified mask, into configuration. Included files should consist of syntactically correct directives and blocks.

---

<div class="post-metadata">

**Author:** ![anagio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/977dab/32.png) [@anagio](https://www.ruby-forum.com/u/anagio)\
**Post date:** [November 28, 2011, 12:53pm UTC](https://www.ruby-forum.com/t/is-it-possible-to-use-a-remote-file-to-store-servernames-server-name-somevariable-file/214310/3 "2011-11-28T12:53:51Z")

</div>

Isn’t include only for nginx.conf file? How would I add this to the  
sites-available/server file to include a remote file with list of  
sub-domains?

Posted at Nginx Forum:

> **[Re: Is it possible to use a remote file to store servernames? server\_name...](https://forum.nginx.org/read.php?2,219193,219202#msg-219202)**
>
> I need to add a lot of sub-domains to a configuration file as users register on our website our script needs to add the sub-domain. Is it possible to use a variable or function in the config file so it loads a remote file which has sub-domains listed...

---

<div class="post-metadata">

**Author:** ![anagio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/977dab/32.png) [@anagio](https://www.ruby-forum.com/u/anagio)\
**Post date:** [November 28, 2011, 1:03pm UTC](https://www.ruby-forum.com/t/is-it-possible-to-use-a-remote-file-to-store-servernames-server-name-somevariable-file/214310/4 "2011-11-28T13:03:47Z")

</div>

On Mon, Nov 28, 2011 at 06:52:59AM -0500, anagio wrote:

> Isn’t include only for nginx.conf file? How would I add this to the  
> sites-available/server file to include a remote file with list of  
> sub-domains?

You can rsync/scp/curl/whatever the file in your preferable  
format (with server names one per line), then generate an  
nginx.conf syntax-compliant file with “server\_name XXX;”  
lines, then send the HUP signal (for details, please see  
[Controlling nginx](http://nginx.org/en/docs/control.html)) to the master nginx  
process, and have it update the configuration on the fly.  
It’s all pretty easy to achieve, and doesn’t require adding  
the “fetching” functionality to nginx.
