Yes, I thought about using an external macro processor to achieve the desired effect, but was hoping I could do without that.<div><br></div><div>So you are saying that even though it works for the $rootfolder in my example, it is setting it to that value on each request. Which is using it in an unintended and inefficient way?<br>
<br></div><div>Thanks.</div><div><br><div class="gmail_quote">On Fri, Oct 22, 2010 at 11:40 AM, Maxim Dounin <span dir="ltr"><<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hello!<br>
<div class="im"><br>
On Fri, Oct 22, 2010 at 08:27:52AM -0400, Arthur Blake wrote:<br>
<br>
> It seems like the set command was designed for use in a narrow set of<br>
> circumstances. But I think it would be a lot more useful if the variables<br>
> it defines could be used globally with any directive.<br>
><br>
> I am trying to use the 'set' command in order to define my own variables<br>
> that define things that may vary by server in a main nginx.conf file so that<br>
> a generic reusable include file can later use those variables. It seems<br>
> that the variables only work in certain places with certain directives.<br>
<br>
</div>In nginx, variables are not something which "may vary by server", it's<br>
something which is request-specific and evaluated at runtime.<br>
<br>
Something which vary on per-server basis (usually referred as<br>
"configuration macros" here) isn't present in nginx at all.<br>
Consider using your favorite template engine (e.g. make + sed) or<br>
try server-specific includes.<br>
<div class="im"><br>
> Is there a reason I can't use variables set this way more widely? I would<br>
> like to be able to use variables like this anywhere in the config files.<br>
><br>
> In the example below, I define two variables with the 'set' command,<br>
> $rootfolder and $backend.<br>
><br>
> The $rootfolder variable doesn't work with the include directive and the<br>
<br>
</div>Include directives are evaluated during configuration parsing on<br>
server startup. There is no request being processed, and no<br>
variables.<br>
<div class="im"><br>
> $backend doesn't work with the proxy_pass directive.<br>
<br>
</div>Actually it does (since 0.6.18). Though this requires resolver to<br>
be defined and implies address parsing and resolving if backend<br>
address given as domain name. Additionally, it has another<br>
semantics than normal proxy_pass - with variables you have to<br>
specify full url of the resource to request (or only server,<br>
0.8.25+), semantics of "proxy_pass with URI" doesn't apply.<br>
<font color="#888888"><br>
Maxim Dounin<br>
</font><br>
p.s. Just to summarise the above: you don't need variables, you<br>
need configuration macros. These aren't implemented, but you are<br>
free to use your favorite template engine.<br>
<div><div></div><div class="h5"><br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://nginx.org/mailman/listinfo/nginx" target="_blank">http://nginx.org/mailman/listinfo/nginx</a><br>
</div></div></blockquote></div><br></div>