Linux server.kiran-academy.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
Apache/2.4.57 (Unix) OpenSSL/1.0.2k-fips
: 194.233.91.196 | : 216.73.216.216
Cant Read [ /etc/named.conf ]
7.4.32
finalho
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
README
+ Create Folder
+ Create File
/
usr /
share /
doc /
varnish-5.2.1 /
html /
users-guide /
[ HOME SHELL ]
Name
Size
Permission
Action
command-line.html
10.23
KB
-rw-r--r--
compression.html
11.79
KB
-rw-r--r--
devicedetection.html
21.88
KB
-rw-r--r--
esi.html
11.71
KB
-rw-r--r--
increasing-your-hitrate.html
61.46
KB
-rw-r--r--
index.html
11.92
KB
-rw-r--r--
intro.html
10.24
KB
-rw-r--r--
operation-logging.html
9.3
KB
-rw-r--r--
operation-statistics.html
8.39
KB
-rw-r--r--
params.html
5.66
KB
-rw-r--r--
performance.html
10.05
KB
-rw-r--r--
purging.html
13.81
KB
-rw-r--r--
report.html
5.48
KB
-rw-r--r--
run_cli.html
15.13
KB
-rw-r--r--
run_security.html
17.29
KB
-rw-r--r--
running.html
7.21
KB
-rw-r--r--
sizing-your-cache.html
6.17
KB
-rw-r--r--
storage-backends.html
11.52
KB
-rw-r--r--
troubleshooting.html
16.57
KB
-rw-r--r--
vcl-actions.html
6.04
KB
-rw-r--r--
vcl-backends.html
21.2
KB
-rw-r--r--
vcl-built-in-subs.html
31.33
KB
-rw-r--r--
vcl-example-acls.html
5.87
KB
-rw-r--r--
vcl-example-manipulating-heade...
6.33
KB
-rw-r--r--
vcl-example-manipulating-respo...
6.47
KB
-rw-r--r--
vcl-example-websockets.html
6.95
KB
-rw-r--r--
vcl-examples.html
5.68
KB
-rw-r--r--
vcl-grace.html
9.83
KB
-rw-r--r--
vcl-hashing.html
8.52
KB
-rw-r--r--
vcl-inline-c.html
6.14
KB
-rw-r--r--
vcl-separate.html
13.18
KB
-rw-r--r--
vcl-syntax.html
10.49
KB
-rw-r--r--
vcl-variables.html
5.93
KB
-rw-r--r--
vcl.html
7.72
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : vcl-backends.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Backend servers — Varnish version 5.2.1 documentation</title> <link rel="stylesheet" href="../_static/classic.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '5.2.1', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="top" title="Varnish version 5.2.1 documentation" href="../index.html" /> <link rel="up" title="VCL - Varnish Configuration Language" href="vcl.html" /> <link rel="next" title="Hashing" href="vcl-hashing.html" /> <link rel="prev" title="actions" href="vcl-actions.html" /> </head> <body role="document"> <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-hashing.html" title="Hashing" accesskey="N">next</a> |</li> <li class="right" > <a href="vcl-actions.html" title="actions" accesskey="P">previous</a> |</li> <li class="nav-item nav-item-0"><a href="../index.html">Varnish version 5.2.1 documentation</a> »</li> <li class="nav-item nav-item-1"><a href="index.html" >The Varnish Users Guide</a> »</li> <li class="nav-item nav-item-2"><a href="vcl.html" accesskey="U">VCL - Varnish Configuration Language</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="section" id="backend-servers"> <span id="users-guide-backend-servers"></span><h1>Backend servers<a class="headerlink" href="#backend-servers" title="Permalink to this headline">¶</a></h1> <p>Varnish has a concept of "backend" or "origin" servers. A backend server is the server providing the content Varnish will accelerate.</p> <p>Our first task is to tell Varnish where it can find its backends. Start your favorite text editor and open the relevant VCL file.</p> <p>Somewhere in the top there will be a section that looks a bit like this.:</p> <div class="highlight-default"><div class="highlight"><pre><span></span><span class="c1"># backend default {</span> <span class="c1"># .host = "127.0.0.1";</span> <span class="c1"># .port = "8080";</span> <span class="c1"># }</span> </pre></div> </div> <p>We remove the comment markings in this text stanza making the it look like.:</p> <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">backend</span> <span class="n">default</span> <span class="p">{</span> <span class="o">.</span><span class="n">host</span> <span class="o">=</span> <span class="s2">"127.0.0.1"</span><span class="p">;</span> <span class="o">.</span><span class="n">port</span> <span class="o">=</span> <span class="s2">"8080"</span><span class="p">;</span> <span class="p">}</span> </pre></div> </div> <p>Now, this piece of configuration defines a backend in Varnish called <em>default</em>. When Varnish needs to get content from this backend it will connect to port 8080 on localhost (127.0.0.1).</p> <p>Varnish can have several backends defined you can even join several backends together into clusters of backends for load balancing purposes.</p> </div> <div class="section" id="multiple-backends"> <h1>Multiple backends<a class="headerlink" href="#multiple-backends" title="Permalink to this headline">¶</a></h1> <p>At some point you might need Varnish to cache content from several servers. You might want Varnish to map all the URL into one single host or not. There are lot of options.</p> <p>Lets say we need to introduce a Java application into out PHP web site. Lets say our Java application should handle URL beginning with <cite>/java/</cite>.</p> <p>We manage to get the thing up and running on port 8000. Now, lets have a look at the <cite>default.vcl</cite>.:</p> <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">backend</span> <span class="n">default</span> <span class="p">{</span> <span class="o">.</span><span class="n">host</span> <span class="o">=</span> <span class="s2">"127.0.0.1"</span><span class="p">;</span> <span class="o">.</span><span class="n">port</span> <span class="o">=</span> <span class="s2">"8080"</span><span class="p">;</span> <span class="p">}</span> </pre></div> </div> <p>We add a new backend.:</p> <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">backend</span> <span class="n">java</span> <span class="p">{</span> <span class="o">.</span><span class="n">host</span> <span class="o">=</span> <span class="s2">"127.0.0.1"</span><span class="p">;</span> <span class="o">.</span><span class="n">port</span> <span class="o">=</span> <span class="s2">"8000"</span><span class="p">;</span> <span class="p">}</span> </pre></div> </div> <p>Now we need tell Varnish where to send the difference URL. Lets look at <cite>vcl_recv</cite>.:</p> <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">sub</span> <span class="n">vcl_recv</span> <span class="p">{</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">"^/java/"</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">backend_hint</span> <span class="o">=</span> <span class="n">java</span><span class="p">;</span> <span class="p">}</span> <span class="k">else</span> <span class="p">{</span> <span class="nb">set</span> <span class="n">req</span><span class="o">.</span><span class="n">backend_hint</span> <span class="o">=</span> <span class="n">default</span><span class="p">;</span> <span class="p">}</span> <span class="p">}</span> </pre></div> </div> <p>It's quite simple, really. Lets stop and think about this for a moment. As you can see you can define how you choose backends based on really arbitrary data. You want to send mobile devices to a different backend? No problem. <code class="docutils literal"><span class="pre">if</span> <span class="pre">(req.http.User-agent</span> <span class="pre">~</span> <span class="pre">/mobile/)</span> <span class="pre">..</span></code> should do the trick.</p> <p>Without an explicit backend selection, varnish will continue using the <cite>default</cite> backend. If there is no backend named <cite>default</cite>, the first backend found in the vcl will be used as the default backend.</p> </div> <div class="section" id="backends-and-virtual-hosts-in-varnish"> <h1>Backends and virtual hosts in Varnish<a class="headerlink" href="#backends-and-virtual-hosts-in-varnish" title="Permalink to this headline">¶</a></h1> <p>Varnish fully supports virtual hosts. They might however work in a somewhat counter-intuitive fashion since they are never declared explicitly. You set up the routing of incoming HTTP requests in <cite>vcl_recv</cite>. If you want this routing to be done on the basis of virtual hosts you just need to inspect <cite>req.http.host</cite>.</p> <p>You can have something like this:</p> <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">sub</span> <span class="n">vcl_recv</span> <span class="p">{</span> <span class="k">if</span> <span class="p">(</span><span class="n">req</span><span class="o">.</span><span class="n">http</span><span class="o">.</span><span class="n">host</span> <span class="o">~</span> <span class="s2">"foo.com"</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">backend_hint</span> <span class="o">=</span> <span class="n">foo</span><span class="p">;</span> <span class="p">}</span> <span class="n">elsif</span> <span class="p">(</span><span class="n">req</span><span class="o">.</span><span class="n">http</span><span class="o">.</span><span class="n">host</span> <span class="o">~</span> <span class="s2">"bar.com"</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">backend_hint</span> <span class="o">=</span> <span class="n">bar</span><span class="p">;</span> <span class="p">}</span> <span class="p">}</span> </pre></div> </div> <p>Note that the first regular expressions will match "foo.com", "www.foo.com", "zoop.foo.com" and any other host ending in "foo.com". In this example this is intentional but you might want it to be a bit more tight, maybe relying on the <code class="docutils literal"><span class="pre">==</span></code> operator in stead, like this:</p> <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">sub</span> <span class="n">vcl_recv</span> <span class="p">{</span> <span class="k">if</span> <span class="p">(</span><span class="n">req</span><span class="o">.</span><span class="n">http</span><span class="o">.</span><span class="n">host</span> <span class="o">==</span> <span class="s2">"foo.com"</span> <span class="o">||</span> <span class="n">req</span><span class="o">.</span><span class="n">http</span><span class="o">.</span><span class="n">host</span> <span class="o">==</span> <span class="s2">"www.foo.com"</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">backend_hint</span> <span class="o">=</span> <span class="n">foo</span><span class="p">;</span> <span class="p">}</span> <span class="p">}</span> </pre></div> </div> </div> <div class="section" id="directors"> <span id="users-guide-advanced-backend-servers-directors"></span><h1>Directors<a class="headerlink" href="#directors" title="Permalink to this headline">¶</a></h1> <p>You can also group several backend into a group of backends. These groups are called directors. This will give you increased performance and resilience.</p> <p>You can define several backends and group them together in a director. This requires you to load a VMOD, a Varnish module, and then to call certain actions in <cite>vcl_init</cite>.:</p> <div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">directors</span><span class="p">;</span> <span class="c1"># load the directors</span> <span class="n">backend</span> <span class="n">server1</span> <span class="p">{</span> <span class="o">.</span><span class="n">host</span> <span class="o">=</span> <span class="s2">"192.168.0.10"</span><span class="p">;</span> <span class="p">}</span> <span class="n">backend</span> <span class="n">server2</span> <span class="p">{</span> <span class="o">.</span><span class="n">host</span> <span class="o">=</span> <span class="s2">"192.168.0.10"</span><span class="p">;</span> <span class="p">}</span> <span class="n">sub</span> <span class="n">vcl_init</span> <span class="p">{</span> <span class="n">new</span> <span class="n">bar</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">bar</span><span class="o">.</span><span class="n">add_backend</span><span class="p">(</span><span class="n">server1</span><span class="p">);</span> <span class="n">bar</span><span class="o">.</span><span class="n">add_backend</span><span class="p">(</span><span class="n">server2</span><span class="p">);</span> <span class="p">}</span> <span class="n">sub</span> <span class="n">vcl_recv</span> <span class="p">{</span> <span class="c1"># send all traffic to the bar director:</span> <span class="nb">set</span> <span class="n">req</span><span class="o">.</span><span class="n">backend_hint</span> <span class="o">=</span> <span class="n">bar</span><span class="o">.</span><span class="n">backend</span><span class="p">();</span> <span class="p">}</span> </pre></div> </div> <p>This director is a round-robin director. This means the director will distribute the incoming requests on a round-robin basis. There is also a <em>random</em> director which distributes requests in a, you guessed it, random fashion. If that is not enough, you can also write your own director (see <a class="reference internal" href="../reference/directors.html#ref-writing-a-director"><span class="std std-ref">Writing a Director</span></a>).</p> <p>But what if one of your servers goes down? Can Varnish direct all the requests to the healthy server? Sure it can. This is where the Health Checks come into play.</p> </div> <div class="section" id="health-checks"> <span id="users-guide-advanced-backend-servers-health"></span><h1>Health checks<a class="headerlink" href="#health-checks" title="Permalink to this headline">¶</a></h1> <p>Lets set up a director with two backends and health checks. First let us define the backends:</p> <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">backend</span> <span class="n">server1</span> <span class="p">{</span> <span class="o">.</span><span class="n">host</span> <span class="o">=</span> <span class="s2">"server1.example.com"</span><span class="p">;</span> <span class="o">.</span><span class="n">probe</span> <span class="o">=</span> <span class="p">{</span> <span class="o">.</span><span class="n">url</span> <span class="o">=</span> <span class="s2">"/"</span><span class="p">;</span> <span class="o">.</span><span class="n">timeout</span> <span class="o">=</span> <span class="mi">1</span><span class="n">s</span><span class="p">;</span> <span class="o">.</span><span class="n">interval</span> <span class="o">=</span> <span class="mi">5</span><span class="n">s</span><span class="p">;</span> <span class="o">.</span><span class="n">window</span> <span class="o">=</span> <span class="mi">5</span><span class="p">;</span> <span class="o">.</span><span class="n">threshold</span> <span class="o">=</span> <span class="mi">3</span><span class="p">;</span> <span class="p">}</span> <span class="p">}</span> <span class="n">backend</span> <span class="n">server2</span> <span class="p">{</span> <span class="o">.</span><span class="n">host</span> <span class="o">=</span> <span class="s2">"server2.example.com"</span><span class="p">;</span> <span class="o">.</span><span class="n">probe</span> <span class="o">=</span> <span class="p">{</span> <span class="o">.</span><span class="n">url</span> <span class="o">=</span> <span class="s2">"/"</span><span class="p">;</span> <span class="o">.</span><span class="n">timeout</span> <span class="o">=</span> <span class="mi">1</span><span class="n">s</span><span class="p">;</span> <span class="o">.</span><span class="n">interval</span> <span class="o">=</span> <span class="mi">5</span><span class="n">s</span><span class="p">;</span> <span class="o">.</span><span class="n">window</span> <span class="o">=</span> <span class="mi">5</span><span class="p">;</span> <span class="o">.</span><span class="n">threshold</span> <span class="o">=</span> <span class="mi">3</span><span class="p">;</span> <span class="p">}</span> <span class="p">}</span> </pre></div> </div> <p>What is new here is the <code class="docutils literal"><span class="pre">probe</span></code>. In this example Varnish will check the health of each backend every 5 seconds, timing out after 1 second. Each poll will send a GET request to /. If 3 out of the last 5 polls succeeded the backend is considered healthy, otherwise it will be marked as sick.</p> <p>Refer to the <a class="reference internal" href="../reference/vcl.html#reference-vcl-probes"><span class="std std-ref">Probes</span></a> section in the <a class="reference internal" href="../reference/vcl.html#vcl-7"><span class="std std-ref">VCL</span></a> documentation for more information.</p> <p>Now we define the 'director':</p> <div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">directors</span><span class="p">;</span> <span class="n">sub</span> <span class="n">vcl_init</span> <span class="p">{</span> <span class="n">new</span> <span class="n">vdir</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">vdir</span><span class="o">.</span><span class="n">add_backend</span><span class="p">(</span><span class="n">server1</span><span class="p">);</span> <span class="n">vdir</span><span class="o">.</span><span class="n">add_backend</span><span class="p">(</span><span class="n">server2</span><span class="p">);</span> <span class="p">}</span> </pre></div> </div> <p>You use this <cite>vdir</cite> director as a backend_hint for requests, just like you would with a simple backend. Varnish will not send traffic to hosts that are marked as unhealthy.</p> <p>Varnish can also serve stale content if all the backends are down. See <a class="reference internal" href="vcl-grace.html#users-guide-handling-misbehaving-servers"><span class="std std-ref">Misbehaving servers</span></a> for more information on how to enable this.</p> <p>Please note that Varnish will keep health probes running for all loaded VCLs. Varnish will coalesce probes that seem identical - so be careful not to change the probe config if you do a lot of VCL loading. Unloading the VCL will discard the probes. For more information on how to do this please see ref:<cite>reference-vcl-director</cite>.</p> </div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h3><a href="../index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Backend servers</a></li> <li><a class="reference internal" href="#multiple-backends">Multiple backends</a></li> <li><a class="reference internal" href="#backends-and-virtual-hosts-in-varnish">Backends and virtual hosts in Varnish</a></li> <li><a class="reference internal" href="#directors">Directors</a></li> <li><a class="reference internal" href="#health-checks">Health checks</a></li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="vcl-actions.html" title="previous chapter">actions</a></p> <h4>Next topic</h4> <p class="topless"><a href="vcl-hashing.html" title="next chapter">Hashing</a></p> <div role="note" aria-label="source link"> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../_sources/users-guide/vcl-backends.txt" rel="nofollow">Show Source</a></li> </ul> </div> <div id="searchbox" style="display: none" role="search"> <h3>Quick search</h3> <form class="search" action="../search.html" method="get"> <div><input type="text" name="q" /></div> <div><input type="submit" value="Go" /></div> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> <script type="text/javascript">$('#searchbox').show(0);</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-hashing.html" title="Hashing" >next</a> |</li> <li class="right" > <a href="vcl-actions.html" title="actions" >previous</a> |</li> <li class="nav-item nav-item-0"><a href="../index.html">Varnish version 5.2.1 documentation</a> »</li> <li class="nav-item nav-item-1"><a href="index.html" >The Varnish Users Guide</a> »</li> <li class="nav-item nav-item-2"><a href="vcl.html" >VCL - Varnish Configuration Language</a> »</li> </ul> </div> <div class="footer" role="contentinfo"> © Copyright 2010-2014, Varnish Software AS. Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.9. </div> </body> </html>
Close