Is it possible to have a loop in config?

Casey Rayman casey.rayman at d2sc.com
Thu Jan 31 06:44:16 MSK 2008


Yeah.  Currently doing it with a shell script, but was curious if  
there was a "righter" way.  Thanks for the help.

Thanks,
Casey

On Jan 30, 2008, at 6:52 PM, Eden Li wrote:

> afaik, no. but you can easily hack ERB or some other templating system
> into your deployment process.
>
> ruby -rerb -e 'puts ERB.new(IO.read("nginx.rconf")).result' >  
> nginx.conf
>
> then you could do stuff like:
>
> <% [10, 20, 99].each do |port| %>
>  server {
>    listen <%= port %>;
>    ...
>  }
> <% end %>
>
> mucho ugly, but it makes things shorter :)
>
> On Jan 31, 2008 8:06 AM, Casey Rayman <casey.rayman at d2sc.com> wrote:
>> I'm using nginx as a reverse proxy and so I've got several sites  
>> which
>> use exactly the same config with the exception of the port.  Is there
>> a way to do something like....
>>
>> array {10,20,99}
>>
>> for each i in array {
>>        server {
>>                listen $i;
>>                ...
>>        }
>> }
>>
>> Perhaps an odd question, but nginx has all kinds of useful features
>> I'd never thought of before.
>>
>> Casey
>>
>>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20080130/521b62dc/attachment.html>


More information about the nginx mailing list