Is it possible to have a loop in config?

Igor Sysoev is at rambler-co.ru
Thu Jan 31 09:05:02 MSK 2008


On Wed, Jan 30, 2008 at 06:06:40PM -0600, Casey Rayman 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.

No, nginx has no macro support.

However, if your servers different in port number only, then you can use

   server {
       listen  10;
       listen  20;
       listen  99;
       ...
   }


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list