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">&lt;<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>&gt;</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>
&gt; It seems like the set command was designed for use in a narrow set of<br>
&gt; circumstances.  But I think it would be a lot more useful if the variables<br>
&gt; it defines could be used globally with any directive.<br>
&gt;<br>
&gt; I am trying to use the &#39;set&#39; command in order to define my own variables<br>
&gt; that define things that may vary by server in a main nginx.conf file so that<br>
&gt; a generic reusable include file can later use those variables.  It seems<br>
&gt; that the variables only work in certain places with certain directives.<br>
<br>
</div>In nginx, variables are not something which &quot;may vary by server&quot;, it&#39;s<br>
something which is request-specific and evaluated at runtime.<br>
<br>
Something which vary on per-server basis (usually referred as<br>
&quot;configuration macros&quot; here) isn&#39;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>
&gt; Is there a reason I can&#39;t use variables set this way more widely?  I would<br>
&gt; like to be able to use variables like this anywhere in the config files.<br>
&gt;<br>
&gt; In the example below, I define two variables with the &#39;set&#39; command,<br>
&gt; $rootfolder and $backend.<br>
&gt;<br>
&gt; The $rootfolder variable doesn&#39;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>
&gt; $backend doesn&#39;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 &quot;proxy_pass with URI&quot; doesn&#39;t apply.<br>
<font color="#888888"><br>
Maxim Dounin<br>
</font><br>
p.s. Just to summarise the above: you don&#39;t need variables, you<br>
need configuration macros.  These aren&#39;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>