⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.96
Server IP:
147.93.97.220
Server:
Linux srv843233 6.8.0-71-generic #71-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 16:52:38 UTC 2025 x86_64
Server Software:
nginx/1.28.0
PHP Version:
8.2.29
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
doc
/
varnish
/
html
/
reference
/
View File Name :
vcl.html
<!DOCTYPE html> <html lang="en" data-content_root="../"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" /> <title>VCL — Varnish version 7.5.0 documentation</title> <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=fa44fd50" /> <link rel="stylesheet" type="text/css" href="../_static/classic.css?v=e2714048" /> <script src="../_static/documentation_options.js?v=8214db13"></script> <script src="../_static/doctools.js?v=888ff710"></script> <script src="../_static/sphinx_highlight.js?v=dc90522c"></script> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="next" title="VCL-Variables" href="vcl-var.html" /> <link rel="prev" title="The Varnish Reference Manual" href="index.html" /> </head><body> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="vcl-var.html" title="VCL-Variables" accesskey="N">next</a> |</li> <li class="right" > <a href="index.html" title="The Varnish Reference Manual" accesskey="P">previous</a> |</li> <li class="nav-item nav-item-0"><a href="../index.html">Varnish version 7.5.0 documentation</a> »</li> <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">The Varnish Reference Manual</a> »</li> <li class="nav-item nav-item-this"><a href="">VCL</a></li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <section id="vcl"> <span id="vcl-7"></span><h1>VCL<a class="headerlink" href="#vcl" title="Link to this heading">¶</a></h1> <section id="varnish-configuration-language"> <h2>Varnish Configuration Language<a class="headerlink" href="#varnish-configuration-language" title="Link to this heading">¶</a></h2> <dl class="field-list simple"> <dt class="field-odd">Manual section<span class="colon">:</span></dt> <dd class="field-odd"><p>7</p> </dd> </dl> <section id="description"> <h3>DESCRIPTION<a class="headerlink" href="#description" title="Link to this heading">¶</a></h3> <p>The VCL language is a small domain-specific language designed to be used to describe request handling and document caching policies for Varnish Cache.</p> <p>When a new configuration is loaded, the varnishd management process translates the VCL code to C and compiles it to a shared object which is then loaded into the server process.</p> <p>This document focuses on the syntax of the VCL language. For a full description of syntax and semantics, with ample examples, please see the online documentation at <a class="reference external" href="https://www.varnish-cache.org/docs/">https://www.varnish-cache.org/docs/</a> .</p> <p>Starting with Varnish 4.0, each VCL file must start by declaring its version with <code class="docutils literal notranslate"><span class="pre">vcl</span></code> <em><major>.<minor></em><code class="docutils literal notranslate"><span class="pre">;</span></code> marker at the top of the file. See more about this under Versioning below.</p> <section id="operators"> <h4>Operators<a class="headerlink" href="#operators" title="Link to this heading">¶</a></h4> <p>The following operators are available in VCL:</p> <blockquote> <div><dl> <dt><code class="docutils literal notranslate"><span class="pre">=</span></code></dt><dd><p>Assignment operator.</p> </dd> <dt><code class="docutils literal notranslate"><span class="pre">+</span></code>, <code class="docutils literal notranslate"><span class="pre">-</span></code>, <code class="docutils literal notranslate"><span class="pre">*</span></code>, <code class="docutils literal notranslate"><span class="pre">/</span></code>, <code class="docutils literal notranslate"><span class="pre">%</span></code></dt><dd><p>Basic math on numerical values.</p> </dd> <dt><code class="docutils literal notranslate"><span class="pre">+=</span></code>, <code class="docutils literal notranslate"><span class="pre">-=</span></code>, <code class="docutils literal notranslate"><span class="pre">*=</span></code>, <code class="docutils literal notranslate"><span class="pre">/=</span></code></dt><dd><p>Assign and increment/decrement/multiply/divide operator.</p> <p>For strings, <code class="docutils literal notranslate"><span class="pre">+=</span></code> appends.</p> </dd> <dt><code class="docutils literal notranslate"><span class="pre">(</span></code>, <code class="docutils literal notranslate"><span class="pre">)</span></code></dt><dd><p>Evaluate separately.</p> </dd> <dt><code class="docutils literal notranslate"><span class="pre">==</span></code>, <code class="docutils literal notranslate"><span class="pre">!=</span></code>, <code class="docutils literal notranslate"><span class="pre"><</span></code>, <code class="docutils literal notranslate"><span class="pre">></span></code>, <code class="docutils literal notranslate"><span class="pre"><=</span></code>, <code class="docutils literal notranslate"><span class="pre">>=</span></code></dt><dd><p>Comparisons</p> </dd> <dt><code class="docutils literal notranslate"><span class="pre">~</span></code>, <code class="docutils literal notranslate"><span class="pre">!~</span></code></dt><dd><p>Match / non-match. Can either be used with regular expressions or ACLs.</p> </dd> <dt><code class="docutils literal notranslate"><span class="pre">!</span></code></dt><dd><p>Negation.</p> </dd> <dt><code class="docutils literal notranslate"><span class="pre">&&</span></code> / <code class="docutils literal notranslate"><span class="pre">||</span></code></dt><dd><p>Logical and/or.</p> </dd> </dl> </div></blockquote> </section> <section id="conditionals"> <h4>Conditionals<a class="headerlink" href="#conditionals" title="Link to this heading">¶</a></h4> <p>VCL has <code class="docutils literal notranslate"><span class="pre">if</span></code> and <code class="docutils literal notranslate"><span class="pre">else</span></code> statements. Nested logic can be implemented with the <code class="docutils literal notranslate"><span class="pre">elseif</span></code> statement (<code class="docutils literal notranslate"><span class="pre">elsif</span></code>/<code class="docutils literal notranslate"><span class="pre">elif</span></code>/<code class="docutils literal notranslate"><span class="pre">else</span> <span class="pre">if</span></code> are equivalent).</p> <p>Note that there are no loops or iterators of any kind in VCL.</p> </section> <section id="variables"> <h4>Variables<a class="headerlink" href="#variables" title="Link to this heading">¶</a></h4> <p>VCL does most of the work by examining, <code class="docutils literal notranslate"><span class="pre">set</span></code>’ing and <code class="docutils literal notranslate"><span class="pre">unset</span></code>’ing variables:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="n">req</span><span class="o">.</span><span class="n">url</span> <span class="o">==</span> <span class="s2">"/mistyped_url.html"</span><span class="p">)</span> <span class="p">{</span> <span class="nb">set</span> <span class="n">req</span><span class="o">.</span><span class="n">url</span> <span class="o">=</span> <span class="s2">"/correct_url.html"</span><span class="p">;</span> <span class="n">unset</span> <span class="n">req</span><span class="o">.</span><span class="n">http</span><span class="o">.</span><span class="n">cookie</span><span class="p">;</span> <span class="p">}</span> </pre></div> </div> <p>There are obvious limitations to what can be done, for instance it makes no sense to <code class="docutils literal notranslate"><span class="pre">unset</span> <span class="pre">req.url;</span></code> - a request must have some kind of URL to be valid, and likewise trying to manipulate a backend response when there is none (yet) makes no sense. The VCL compiler will detect such errors.</p> <p>Variables have types. Most of them a STRINGS, and anything in VCL can be turned into a STRING, but some variables have types like <code class="docutils literal notranslate"><span class="pre">DURATION</span></code>, <code class="docutils literal notranslate"><span class="pre">IP</span></code> etc.</p> <p>When setting a such variables, the right hand side of the equal sign must have the correct variables type, you cannot assign a STRING to a variable of type NUMBER, even if the string is <code class="docutils literal notranslate"><span class="pre">"42"</span></code>.</p> <p>Explicit conversion functions are available in <a class="reference internal" href="vmod_std.html#vmod-std-3"><span class="std std-ref">VMOD std - Varnish Standard Module</span></a>.</p> <p>For the complete album of VCL variables see: <a class="reference internal" href="vcl-var.html#vcl-var-7"><span class="std std-ref">VCL-Variables</span></a>.</p> <section id="strings"> <h5>Strings<a class="headerlink" href="#strings" title="Link to this heading">¶</a></h5> <p>Basic strings are enclosed in double quotes <code class="docutils literal notranslate"><span class="pre">"</span></code><em>…</em><code class="docutils literal notranslate"><span class="pre">"</span></code>, and may not contain newlines. Long strings are enclosed in <code class="docutils literal notranslate"><span class="pre">{"</span></code><em>…</em><code class="docutils literal notranslate"><span class="pre">"}</span></code> or <code class="docutils literal notranslate"><span class="pre">"""</span></code><em>…</em><code class="docutils literal notranslate"><span class="pre">"""</span></code>. They may contain any character including single double quotes <code class="docutils literal notranslate"><span class="pre">"</span></code>, newline and other control characters except for the <em>NUL</em> (0x00) character.</p> </section> <section id="booleans"> <h5>Booleans<a class="headerlink" href="#booleans" title="Link to this heading">¶</a></h5> <p>Booleans can be either <code class="docutils literal notranslate"><span class="pre">true</span></code> or <code class="docutils literal notranslate"><span class="pre">false</span></code>. In addition, in a boolean context some data types will evaluate to <code class="docutils literal notranslate"><span class="pre">true</span></code> or <code class="docutils literal notranslate"><span class="pre">false</span></code> depending on their value.</p> <p>String types will evaluate to <code class="docutils literal notranslate"><span class="pre">false</span></code> if they are unset. This allows checks of the type <code class="docutils literal notranslate"><span class="pre">if</span> <span class="pre">(req.http.opthdr)</span> <span class="pre">{}</span></code> to test if a header exists, even if it is empty, whereas <code class="docutils literal notranslate"><span class="pre">if</span> <span class="pre">(req.http.opthdr</span> <span class="pre">==</span> <span class="pre">"")</span> <span class="pre">{}</span></code> does not distinguish if the header does not exist or if it is empty.</p> <p>Backend types will evaluate to <code class="docutils literal notranslate"><span class="pre">false</span></code> if they don’t have a backend assigned; integer types will evaluate to <code class="docutils literal notranslate"><span class="pre">false</span></code> if their value is zero; duration types will evaluate to <code class="docutils literal notranslate"><span class="pre">false</span></code> if their value is equal or less than zero.</p> </section> <section id="time"> <h5>Time<a class="headerlink" href="#time" title="Link to this heading">¶</a></h5> <p>VCL has time. A duration can be added to a time to make another time. In string context they return a formatted string in RFC1123 format, e.g. <code class="docutils literal notranslate"><span class="pre">Sun,</span> <span class="pre">06</span> <span class="pre">Nov</span> <span class="pre">1994</span> <span class="pre">08:49:37</span> <span class="pre">GMT</span></code>.</p> <p>The keyword <code class="docutils literal notranslate"><span class="pre">now</span></code> returns a notion of the current time, which is kept consistent during VCL subroutine invocations, so during the execution of a VCL state subroutine (<code class="docutils literal notranslate"><span class="pre">vcl_*</span> <span class="pre">{}</span></code>), including all user-defined subroutines being called, <code class="docutils literal notranslate"><span class="pre">now</span></code> always returns the same value.</p> </section> <section id="durations"> <span id="vcl-7-durations"></span><h5>Durations<a class="headerlink" href="#durations" title="Link to this heading">¶</a></h5> <p>Durations are defined by a number followed by a unit. The number can include a fractional part, e.g. <code class="docutils literal notranslate"><span class="pre">1.5s</span></code>. The supported units are:</p> <blockquote> <div><dl class="simple"> <dt><code class="docutils literal notranslate"><span class="pre">ms</span></code></dt><dd><p>milliseconds</p> </dd> <dt><code class="docutils literal notranslate"><span class="pre">s</span></code></dt><dd><p>seconds</p> </dd> <dt><code class="docutils literal notranslate"><span class="pre">m</span></code></dt><dd><p>minutes</p> </dd> <dt><code class="docutils literal notranslate"><span class="pre">h</span></code></dt><dd><p>hours</p> </dd> <dt><code class="docutils literal notranslate"><span class="pre">d</span></code></dt><dd><p>days</p> </dd> <dt><code class="docutils literal notranslate"><span class="pre">w</span></code></dt><dd><p>weeks</p> </dd> <dt><code class="docutils literal notranslate"><span class="pre">y</span></code></dt><dd><p>years</p> </dd> </dl> </div></blockquote> <p>In string context they return a string with their value rounded to 3 decimal places and excluding the unit, e.g. <code class="docutils literal notranslate"><span class="pre">1.500</span></code>.</p> </section> <section id="integers"> <h5>Integers<a class="headerlink" href="#integers" title="Link to this heading">¶</a></h5> <p>Certain fields are integers, used as expected. In string context they return a string, e.g. <code class="docutils literal notranslate"><span class="pre">1234</span></code>.</p> </section> <section id="real-numbers"> <h5>Real numbers<a class="headerlink" href="#real-numbers" title="Link to this heading">¶</a></h5> <p>VCL understands real numbers. In string context they return a string with their value rounded to 3 decimal places, e.g. <code class="docutils literal notranslate"><span class="pre">3.142</span></code>.</p> </section> </section> <section id="regular-expressions"> <h4>Regular Expressions<a class="headerlink" href="#regular-expressions" title="Link to this heading">¶</a></h4> <p>Varnish uses Perl-compatible regular expressions (PCRE). For a complete description please see the pcre(3) man page.</p> <p>To send flags to the PCRE engine, such as to do case insensitive matching, add the flag within parens following a question mark, like this:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span># If host is NOT example dot com.. if (req.http.host !~ "(?i)example\.com$") { ... } </pre></div> </div> </section> <section id="include-statement"> <span id="vcl-include"></span><h4>Include statement<a class="headerlink" href="#include-statement" title="Link to this heading">¶</a></h4> <p>To include a VCL file in another file use the <code class="docutils literal notranslate"><span class="pre">include</span></code> keyword:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">include</span> <span class="s2">"foo.vcl"</span><span class="p">;</span> </pre></div> </div> <p>Optionally, the <code class="docutils literal notranslate"><span class="pre">include</span></code> keyword can take a <code class="docutils literal notranslate"><span class="pre">+glob</span></code> flag to include all files matching a glob pattern:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">include</span> <span class="o">+</span><span class="n">glob</span> <span class="s2">"example.org/*.vcl"</span><span class="p">;</span> </pre></div> </div> </section> <section id="import-statement"> <h4>Import statement<a class="headerlink" href="#import-statement" title="Link to this heading">¶</a></h4> <p>The <code class="docutils literal notranslate"><span class="pre">import</span></code> statement is used to load Varnish Modules (VMODs.)</p> <p>Example:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">std</span><span class="p">;</span> <span class="n">sub</span> <span class="n">vcl_recv</span> <span class="p">{</span> <span class="n">std</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="s2">"foo"</span><span class="p">);</span> <span class="p">}</span> </pre></div> </div> </section> <section id="comments"> <h4>Comments<a class="headerlink" href="#comments" title="Link to this heading">¶</a></h4> <p>Single lines of VCL can be commented out using <code class="docutils literal notranslate"><span class="pre">//</span></code> or <code class="docutils literal notranslate"><span class="pre">#</span></code>. Multi-line blocks can be commented out with <code class="docutils literal notranslate"><span class="pre">/*</span></code><em>block</em><code class="docutils literal notranslate"><span class="pre">*/</span></code>.</p> <p>Example:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sub</span> <span class="n">vcl_recv</span> <span class="p">{</span> <span class="o">//</span> <span class="n">Single</span> <span class="n">line</span> <span class="n">of</span> <span class="n">out</span><span class="o">-</span><span class="n">commented</span> <span class="n">VCL</span><span class="o">.</span> <span class="c1"># Another way of commenting out a single line.</span> <span class="o">/*</span> <span class="n">Multi</span><span class="o">-</span><span class="n">line</span> <span class="n">block</span> <span class="n">of</span> <span class="n">commented</span><span class="o">-</span><span class="n">out</span> <span class="n">VCL</span><span class="o">.</span> <span class="o">*/</span> <span class="p">}</span> </pre></div> </div> </section> <section id="backends-and-health-probes"> <h4>Backends and health probes<a class="headerlink" href="#backends-and-health-probes" title="Link to this heading">¶</a></h4> <p>Please see <a class="reference internal" href="vcl-backend.html#vcl-backend-7"><span class="std std-ref">VCL-backends</span></a> and <a class="reference internal" href="vcl-probe.html#vcl-probe-7"><span class="std std-ref">VCL-probe</span></a></p> </section> <section id="access-control-list-acl"> <span id="vcl-acl"></span><h4>Access Control List (ACL)<a class="headerlink" href="#access-control-list-acl" title="Link to this heading">¶</a></h4> <p>An Access Control List (ACL) declaration creates and initialises a named access control list which can later be used to match client addresses:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>acl localnetwork { "localhost"; # myself "192.0.2.0"/24; # and everyone on the local network ! "192.0.2.23"; # except for the dial-in router } </pre></div> </div> <p>If an ACL entry specifies a host name which Varnish is unable to resolve, it will match any address it is compared to. Consequently, if it is preceded by a negation mark, it will reject any address it is compared to, which may not be what you intended. If the entry is enclosed in parentheses, however, it will simply be ignored if the host name cannot be resolved.</p> <p>To match an IP address against an ACL, simply use the match operator:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="n">client</span><span class="o">.</span><span class="n">ip</span> <span class="o">~</span> <span class="n">localnetwork</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="p">(</span><span class="n">pipe</span><span class="p">);</span> <span class="p">}</span> </pre></div> </div> <p>ACLs have feature flags which can be set or cleared for each ACL individually:</p> <ul> <li><p><cite>+log</cite> - Emit a <cite>Acl</cite> record in VSL to tell if a match was found or not.</p></li> <li><p><cite>+table</cite> - Implement the ACL with a table instead of compiled code. This runs a little bit slower, but compiles large ACLs much faster.</p></li> <li><p><cite>-pedantic</cite> - Allow masks to cover non-zero host-bits. This allows the following to work:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">acl</span> <span class="n">foo</span> <span class="o">-</span><span class="n">pedantic</span> <span class="o">+</span><span class="n">log</span> <span class="p">{</span> <span class="s2">"firewall.example.com"</span> <span class="o">/</span> <span class="mi">24</span><span class="p">;</span> <span class="p">}</span> </pre></div> </div> <p>However, if the name resolves to both IPv4 and IPv6 you will still get an error.</p> </li> <li><p><cite>+fold</cite> - Fold ACL supernets and adjacent networks.</p> <p>With this parameter set to on, ACLs are optimized in that subnets contained in other entries are skipped (e.g. if 1.2.3.0/24 is part of the ACL, an entry for 1.2.3.128/25 will not be added) and adjacent entries get folded (e.g. if both 1.2.3.0/25 and 1.2.3.128/25 are added, they will be folded to 1.2.3.0/24).</p> <p>Skip and fold operations on VCL entries are output as warnings during VCL compilation as entries from the VCL are processed in order.</p> <p>Logging under the <code class="docutils literal notranslate"><span class="pre">VCL_acl</span></code> tag can change with this parameter enabled: Matches on skipped subnet entries are now logged as matches on the respective supernet entry. Matches on folded entries are logged with a shorter netmask which might not be contained in the original ACL as defined in VCL. Such log entries are marked by <code class="docutils literal notranslate"><span class="pre">fixed:</span> <span class="pre">folded</span></code>.</p> <p>Negated ACL entries are never folded.</p> </li> </ul> </section> <section id="vcl-objects"> <h4>VCL objects<a class="headerlink" href="#vcl-objects" title="Link to this heading">¶</a></h4> <p>A VCL object can be instantiated with the <code class="docutils literal notranslate"><span class="pre">new</span></code> keyword:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sub</span> <span class="n">vcl_init</span> <span class="p">{</span> <span class="n">new</span> <span class="n">b</span> <span class="o">=</span> <span class="n">directors</span><span class="o">.</span><span class="n">round_robin</span><span class="p">()</span> <span class="n">b</span><span class="o">.</span><span class="n">add_backend</span><span class="p">(</span><span class="n">node1</span><span class="p">);</span> <span class="p">}</span> </pre></div> </div> <p>This is only available in <code class="docutils literal notranslate"><span class="pre">vcl_init</span></code>.</p> </section> <section id="subroutines"> <h4>Subroutines<a class="headerlink" href="#subroutines" title="Link to this heading">¶</a></h4> <p>A subroutine is used to group code for legibility or reusability:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sub</span> <span class="n">pipe_if_local</span> <span class="p">{</span> <span class="k">if</span> <span class="p">(</span><span class="n">client</span><span class="o">.</span><span class="n">ip</span> <span class="o">~</span> <span class="n">localnetwork</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="p">(</span><span class="n">pipe</span><span class="p">);</span> <span class="p">}</span> <span class="p">}</span> </pre></div> </div> <p>Subroutines in VCL do not take arguments, nor do they return values. The built in subroutines all have names beginning with <code class="docutils literal notranslate"><span class="pre">vcl_</span></code>, which is reserved.</p> <p>To call a subroutine, use the <code class="docutils literal notranslate"><span class="pre">call</span></code> keyword followed by the subroutine’s name:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sub</span> <span class="n">vcl_recv</span> <span class="p">{</span> <span class="n">call</span> <span class="n">pipe_if_local</span><span class="p">;</span> <span class="p">}</span> </pre></div> </div> <section id="return-statements"> <h5>Return statements<a class="headerlink" href="#return-statements" title="Link to this heading">¶</a></h5> <p>The ongoing <code class="docutils literal notranslate"><span class="pre">vcl_*</span></code> subroutine execution ends when a <code class="docutils literal notranslate"><span class="pre">return(</span></code><em><action></em><code class="docutils literal notranslate"><span class="pre">)</span></code> statement is made.</p> <p>The <em><action></em> specifies how execution should proceed. The context defines which actions are available.</p> <p>It is possible to exit a subroutine that is not part of the built-in ones using a simple <code class="docutils literal notranslate"><span class="pre">return</span></code> statement without specifying an action. It exits the subroutine without transitioning to a different state:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>sub filter_cookies { if (!req.http.cookie) { return; } # complex cookie filtering } </pre></div> </div> </section> <section id="multiple-subroutines"> <h5>Multiple subroutines<a class="headerlink" href="#multiple-subroutines" title="Link to this heading">¶</a></h5> <p>If multiple subroutines with the name of one of the built-in ones are defined, they are concatenated in the order in which they appear in the source.</p> <p>The built-in VCL distributed with Varnish will be implicitly concatenated when the VCL is compiled.</p> </section> </section> <section id="functions"> <h4>Functions<a class="headerlink" href="#functions" title="Link to this heading">¶</a></h4> <p>The following built-in functions are available:</p> <section id="ban-string"> <span id="vcl-7-ban"></span><h5>ban(STRING)<a class="headerlink" href="#ban-string" title="Link to this heading">¶</a></h5> <blockquote> <div><p>Deprecated. See <a class="reference internal" href="vmod_std.html#std-ban"><span class="std std-ref">BOOL ban(STRING)</span></a>.</p> <p>The <code class="docutils literal notranslate"><span class="pre">ban()</span></code> function is identical to <a class="reference internal" href="vmod_std.html#std-ban"><span class="std std-ref">BOOL ban(STRING)</span></a>, but does not provide error reporting.</p> </div></blockquote> </section> <section id="hash-data-input"> <h5>hash_data(input)<a class="headerlink" href="#hash-data-input" title="Link to this heading">¶</a></h5> <blockquote> <div><p>Adds an input to the hash input. In the built-in VCL <code class="docutils literal notranslate"><span class="pre">hash_data()</span></code> is called on the host and URL of the request. Available in <code class="docutils literal notranslate"><span class="pre">vcl_hash</span></code>.</p> </div></blockquote> </section> <section id="synthetic-string"> <h5>synthetic(STRING)<a class="headerlink" href="#synthetic-string" title="Link to this heading">¶</a></h5> <blockquote> <div><p>Prepare a synthetic response body containing the <em>STRING</em>. Available in <code class="docutils literal notranslate"><span class="pre">vcl_synth</span></code> and <code class="docutils literal notranslate"><span class="pre">vcl_backend_error</span></code>.</p> <p>Identical to <code class="docutils literal notranslate"><span class="pre">set</span> <span class="pre">resp.body</span></code> / <code class="docutils literal notranslate"><span class="pre">set</span> <span class="pre">beresp.body</span></code>.</p> </div></blockquote> </section> <section id="regsub-str-regex-sub"> <h5>regsub(str, regex, sub)<a class="headerlink" href="#regsub-str-regex-sub" title="Link to this heading">¶</a></h5> <blockquote> <div><p>Returns a copy of <em>str</em> with the first occurrence of the regular expression <em>regex</em> replaced with <em>sub</em>. Within <em>sub</em>, <code class="docutils literal notranslate"><span class="pre">\0</span></code> (which can also be spelled <code class="docutils literal notranslate"><span class="pre">\&</span></code>) is replaced with the entire matched string, and <code class="docutils literal notranslate"><span class="pre">\</span></code><em>n</em> is replaced with the contents of subgroup <em>n</em> in the matched string.</p> </div></blockquote> </section> <section id="regsuball-str-regex-sub"> <h5>regsuball(str, regex, sub)<a class="headerlink" href="#regsuball-str-regex-sub" title="Link to this heading">¶</a></h5> <blockquote> <div><p>As <code class="docutils literal notranslate"><span class="pre">regsub()</span></code>, but this replaces all occurrences.</p> </div></blockquote> <p>For converting or casting VCL values between data types use the functions available in the std VMOD.</p> </section> </section> </section> <section id="versioning"> <h3>Versioning<a class="headerlink" href="#versioning" title="Link to this heading">¶</a></h3> <p>Multiple versions of the VCL syntax can coexist within certain constraints.</p> <p>The VCL syntax version at the start of VCL file specified with <code class="docutils literal notranslate"><span class="pre">-f</span></code> sets the hard limit that cannot be exceeded anywhere, and it selects the appropriate version of the builtin VCL.</p> <p>That means that you can never include <code class="docutils literal notranslate"><span class="pre">vcl</span> <span class="pre">9.1;</span></code> from <code class="docutils literal notranslate"><span class="pre">vcl</span> <span class="pre">8.7;</span></code>, but the opposite <em>may</em> be possible, to the extent the compiler supports it.</p> <p>Files pulled in via <code class="docutils literal notranslate"><span class="pre">include</span></code> do not need to have a <code class="docutils literal notranslate"><span class="pre">vcl</span></code> <em>X.Y</em><code class="docutils literal notranslate"><span class="pre">;</span></code> but it may be a good idea to do it anyway, to not have surprises in the future. The syntax version set in an included file only applies to that file and any files it includes - unless these set their own VCL syntax version.</p> <p>The version of Varnish this file belongs to supports syntax 4.0 and 4.1.</p> </section> <section id="examples"> <h3>EXAMPLES<a class="headerlink" href="#examples" title="Link to this heading">¶</a></h3> <p>For examples, please see the online documentation.</p> </section> <section id="see-also"> <h3>SEE ALSO<a class="headerlink" href="#see-also" title="Link to this heading">¶</a></h3> <ul class="simple"> <li><p><a class="reference internal" href="varnishd.html#varnishd-1"><span class="std std-ref">varnishd</span></a></p></li> <li><p><a class="reference internal" href="vcl-backend.html#vcl-backend-7"><span class="std std-ref">VCL-backends</span></a></p></li> <li><p><a class="reference internal" href="vcl-probe.html#vcl-probe-7"><span class="std std-ref">VCL-probe</span></a></p></li> <li><p><a class="reference internal" href="vcl-step.html#vcl-step-7"><span class="std std-ref">VCL-steps</span></a></p></li> <li><p><a class="reference internal" href="vcl-var.html#vcl-var-7"><span class="std std-ref">VCL-Variables</span></a></p></li> <li><p><a class="reference internal" href="vmod_directors.html#vmod-directors-3"><span class="std std-ref">VMOD directors - Varnish Directors Module</span></a></p></li> <li><p><a class="reference internal" href="vmod_std.html#vmod-std-3"><span class="std std-ref">VMOD std - Varnish Standard Module</span></a></p></li> </ul> </section> <section id="history"> <h3>HISTORY<a class="headerlink" href="#history" title="Link to this heading">¶</a></h3> <p>VCL was developed by Poul-Henning Kamp in cooperation with Verdens Gang AS, Redpill Linpro and Varnish Software. This manual page is written by Per Buer, Poul-Henning Kamp, Martin Blix Grydeland, Kristian Lyngstøl, Lasse Karstensen and others.</p> </section> <section id="copyright"> <h3>COPYRIGHT<a class="headerlink" href="#copyright" title="Link to this heading">¶</a></h3> <p>This document is licensed under the same license as Varnish itself. See LICENSE for details.</p> <ul class="simple"> <li><p>Copyright (c) 2006 Verdens Gang AS</p></li> <li><p>Copyright (c) 2006-2015 Varnish Software AS</p></li> </ul> </section> </section> </section> <div class="clearer"></div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <div> <h3><a href="../index.html">Table of Contents</a></h3> <ul> <li><a class="reference internal" href="#">VCL</a><ul> <li><a class="reference internal" href="#varnish-configuration-language">Varnish Configuration Language</a><ul> <li><a class="reference internal" href="#description">DESCRIPTION</a><ul> <li><a class="reference internal" href="#operators">Operators</a></li> <li><a class="reference internal" href="#conditionals">Conditionals</a></li> <li><a class="reference internal" href="#variables">Variables</a><ul> <li><a class="reference internal" href="#strings">Strings</a></li> <li><a class="reference internal" href="#booleans">Booleans</a></li> <li><a class="reference internal" href="#time">Time</a></li> <li><a class="reference internal" href="#durations">Durations</a></li> <li><a class="reference internal" href="#integers">Integers</a></li> <li><a class="reference internal" href="#real-numbers">Real numbers</a></li> </ul> </li> <li><a class="reference internal" href="#regular-expressions">Regular Expressions</a></li> <li><a class="reference internal" href="#include-statement">Include statement</a></li> <li><a class="reference internal" href="#import-statement">Import statement</a></li> <li><a class="reference internal" href="#comments">Comments</a></li> <li><a class="reference internal" href="#backends-and-health-probes">Backends and health probes</a></li> <li><a class="reference internal" href="#access-control-list-acl">Access Control List (ACL)</a></li> <li><a class="reference internal" href="#vcl-objects">VCL objects</a></li> <li><a class="reference internal" href="#subroutines">Subroutines</a><ul> <li><a class="reference internal" href="#return-statements">Return statements</a></li> <li><a class="reference internal" href="#multiple-subroutines">Multiple subroutines</a></li> </ul> </li> <li><a class="reference internal" href="#functions">Functions</a><ul> <li><a class="reference internal" href="#ban-string">ban(STRING)</a></li> <li><a class="reference internal" href="#hash-data-input">hash_data(input)</a></li> <li><a class="reference internal" href="#synthetic-string">synthetic(STRING)</a></li> <li><a class="reference internal" href="#regsub-str-regex-sub">regsub(str, regex, sub)</a></li> <li><a class="reference internal" href="#regsuball-str-regex-sub">regsuball(str, regex, sub)</a></li> </ul> </li> </ul> </li> <li><a class="reference internal" href="#versioning">Versioning</a></li> <li><a class="reference internal" href="#examples">EXAMPLES</a></li> <li><a class="reference internal" href="#see-also">SEE ALSO</a></li> <li><a class="reference internal" href="#history">HISTORY</a></li> <li><a class="reference internal" href="#copyright">COPYRIGHT</a></li> </ul> </li> </ul> </li> </ul> </div> <div> <h4>Previous topic</h4> <p class="topless"><a href="index.html" title="previous chapter">The Varnish Reference Manual</a></p> </div> <div> <h4>Next topic</h4> <p class="topless"><a href="vcl-var.html" title="next chapter">VCL-Variables</a></p> </div> <div role="note" aria-label="source link"> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../_sources/reference/vcl.rst.txt" rel="nofollow">Show Source</a></li> </ul> </div> <div id="searchbox" style="display: none" role="search"> <h3 id="searchlabel">Quick search</h3> <div class="searchformwrapper"> <form class="search" action="../search.html" method="get"> <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/> <input type="submit" value="Go" /> </form> </div> </div> <script>document.getElementById('searchbox').style.display = "block"</script> </div> </div> <div class="clearer"></div> </div> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="vcl-var.html" title="VCL-Variables" >next</a> |</li> <li class="right" > <a href="index.html" title="The Varnish Reference Manual" >previous</a> |</li> <li class="nav-item nav-item-0"><a href="../index.html">Varnish version 7.5.0 documentation</a> »</li> <li class="nav-item nav-item-1"><a href="index.html" >The Varnish Reference Manual</a> »</li> <li class="nav-item nav-item-this"><a href="">VCL</a></li> </ul> </div> <div class="footer" role="contentinfo"> © Copyright 2010-2014, Varnish Software AS. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.2.6. </div> </body> </html>