Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nginx
GitHub Repository: nginx/nginx.org
Path: blob/main/xml/en/docs/faq/variables_in_config.xml
1 views
1
<!--
2
Copyright (C) Nginx, Inc.
3
-->
4
5
<!DOCTYPE article SYSTEM "../../../../dtd/article.dtd">
6
7
<article name="Is there a proper way to use nginx variables to
8
make sections of the configuration shorter,
9
using them as macros for making
10
parts of configuration work as templates?"
11
link="/en/docs/faq/variables_in_config.html"
12
lang="en"
13
rev="1">
14
15
<section>
16
17
<para>
18
<initial>Q:</initial>
19
Is there a proper way to use nginx variables to make sections of
20
the configuration shorter, using them as macros for making
21
parts of configuration work as templates?
22
</para>
23
24
<para>
25
&nbsp;
26
</para>
27
28
<para>
29
<initial>A:</initial>
30
Variables should not be used as template macros. Variables are
31
evaluated in the run-time during the processing of each
32
request, so they are rather costly compared to plain static
33
configuration. Using variables to store static strings is also
34
a bad idea. Instead, a macro expansion and "include" directives
35
should be used to generate configs more easily and it can be
36
done with the external tools, e.g. sed + make or any other
37
common template mechanism.
38
</para>
39
40
</section>
41
42
</article>
43
44