~ubuntu-branches/debian/sid/varnish/sid

« back to all changes in this revision

Viewing changes to doc/sphinx/=build/html/faq/http.html

  • Committer: Package Import Robot
  • Author(s): Stig Sandbeck Mathisen
  • Date: 2011-10-29 15:23:24 UTC
  • mfrom: (0.1.15)
  • Revision ID: package-import@ubuntu.com-20111029152324-tdtlsurrv22ysknj
Tags: 3.0.2-1
* New upstream release
* Build from upstream tarball instead of git tag
* debian/watch: more specific regular expression

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
 
 
3
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
4
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
5
 
 
6
<html xmlns="http://www.w3.org/1999/xhtml">
 
7
  <head>
 
8
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
9
    
 
10
    <title>HTTP &mdash; Varnish version 3.0.2 documentation</title>
 
11
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
 
12
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
 
13
    <script type="text/javascript">
 
14
      var DOCUMENTATION_OPTIONS = {
 
15
        URL_ROOT:    '../',
 
16
        VERSION:     '3.0.2',
 
17
        COLLAPSE_INDEX: false,
 
18
        FILE_SUFFIX: '.html',
 
19
        HAS_SOURCE:  true
 
20
      };
 
21
    </script>
 
22
    <script type="text/javascript" src="../_static/jquery.js"></script>
 
23
    <script type="text/javascript" src="../_static/underscore.js"></script>
 
24
    <script type="text/javascript" src="../_static/doctools.js"></script>
 
25
    <link rel="top" title="Varnish version 3.0.2 documentation" href="../index.html" />
 
26
    <link rel="up" title="Frequently asked questions" href="index.html" />
 
27
    <link rel="next" title="Configuration" href="configuration.html" />
 
28
    <link rel="prev" title="General questions" href="general.html" /> 
 
29
  </head>
 
30
  <body>
 
31
    <div class="related">
 
32
      <h3>Navigation</h3>
 
33
      <ul>
 
34
        <li class="right" style="margin-right: 10px">
 
35
          <a href="../genindex.html" title="General Index"
 
36
             accesskey="I">index</a></li>
 
37
        <li class="right" >
 
38
          <a href="configuration.html" title="Configuration"
 
39
             accesskey="N">next</a> |</li>
 
40
        <li class="right" >
 
41
          <a href="general.html" title="General questions"
 
42
             accesskey="P">previous</a> |</li>
 
43
        <li><a href="../index.html">Varnish version 3.0.2 documentation</a> &raquo;</li>
 
44
          <li><a href="index.html" accesskey="U">Frequently asked questions</a> &raquo;</li> 
 
45
      </ul>
 
46
    </div>  
 
47
 
 
48
    <div class="document">
 
49
      <div class="documentwrapper">
 
50
        <div class="bodywrapper">
 
51
          <div class="body">
 
52
            
 
53
  <div class="section" id="http">
 
54
<h1>HTTP<a class="headerlink" href="#http" title="Permalink to this headline">¶</a></h1>
 
55
<p><strong>What is the purpose of the X-Varnish HTTP header?</strong></p>
 
56
<p>The X-Varnish HTTP header allows you to find the correct log-entries for the transaction. For a cache hit, X-Varnish will contain both the ID of the current request and the ID of the request that populated the cache. It makes debugging Varnish a lot easier.</p>
 
57
<p><strong>Does Varnish support compression?</strong></p>
 
58
<p>This is a simple question with a complicated answer; see <a class="reference external" href="http://varnish-cache.org/wiki/FAQ/Compression">WIKI</a>.</p>
 
59
<p><strong>How do I add a HTTP header?</strong></p>
 
60
<p>To add a HTTP header, unless you want to add something about the client/request, it is best done in vcl_fetch as this means it will only be processed every time the object is fetched:</p>
 
61
<div class="highlight-python"><pre>sub vcl_fetch {
 
62
  # Add a unique header containing the cache servers IP address:
 
63
  remove beresp.http.X-Varnish-IP;
 
64
  set    beresp.http.X-Varnish-IP = server.ip;
 
65
  # Another header:
 
66
  set    beresp.http.Foo = "bar";
 
67
}</pre>
 
68
</div>
 
69
<p><strong>How can I log the client IP address on the backend?</strong></p>
 
70
<p>All I see is the IP address of the varnish server.  How can I log the client IP address?</p>
 
71
<p>We will need to add the IP address to a header used for the backend request, and configure the backend to log the content of this header instead of the address of the connecting client (which is the varnish server).</p>
 
72
<p>Varnish configuration:</p>
 
73
<div class="highlight-python"><pre>sub vcl_recv {
 
74
  # Add a unique header containing the client address
 
75
  remove req.http.X-Forwarded-For;
 
76
  set    req.http.X-Forwarded-For = client.ip;
 
77
  # [...]
 
78
}</pre>
 
79
</div>
 
80
<p>For the apache configuration, we copy the &quot;combined&quot; log format to a new one we call &quot;varnishcombined&quot;, for instance, and change the client IP field to use the content of the variable we set in the varnish configuration:</p>
 
81
<div class="highlight-python"><pre>LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\" \"%{User-Agent}i\"" varnishcombined</pre>
 
82
</div>
 
83
<p>And so, in our virtualhost, you need to specify this format instead of &quot;combined&quot; (or &quot;common&quot;, or whatever else you use):</p>
 
84
<div class="highlight-python"><pre>&lt;VirtualHost *:80&gt;
 
85
  ServerName www.example.com
 
86
  # [...]
 
87
  CustomLog /var/log/apache2/www.example.com/access.log varnishcombined
 
88
  # [...]
 
89
&lt;/VirtualHost&gt;</pre>
 
90
</div>
 
91
<p>The [<a class="reference external" href="http://www.openinfo.co.uk/apache/index.html">http://www.openinfo.co.uk/apache/index.html</a> mod_extract_forwarded Apache module] might also be useful.</p>
 
92
</div>
 
93
 
 
94
 
 
95
          </div>
 
96
        </div>
 
97
      </div>
 
98
      <div class="sphinxsidebar">
 
99
        <div class="sphinxsidebarwrapper">
 
100
  <h4>Previous topic</h4>
 
101
  <p class="topless"><a href="general.html"
 
102
                        title="previous chapter">General questions</a></p>
 
103
  <h4>Next topic</h4>
 
104
  <p class="topless"><a href="configuration.html"
 
105
                        title="next chapter">Configuration</a></p>
 
106
  <h3>This Page</h3>
 
107
  <ul class="this-page-menu">
 
108
    <li><a href="../_sources/faq/http.txt"
 
109
           rel="nofollow">Show Source</a></li>
 
110
  </ul>
 
111
<div id="searchbox" style="display: none">
 
112
  <h3>Quick search</h3>
 
113
    <form class="search" action="../search.html" method="get">
 
114
      <input type="text" name="q" size="18" />
 
115
      <input type="submit" value="Go" />
 
116
      <input type="hidden" name="check_keywords" value="yes" />
 
117
      <input type="hidden" name="area" value="default" />
 
118
    </form>
 
119
    <p class="searchtip" style="font-size: 90%">
 
120
    Enter search terms or a module, class or function name.
 
121
    </p>
 
122
</div>
 
123
<script type="text/javascript">$('#searchbox').show(0);</script>
 
124
        </div>
 
125
      </div>
 
126
      <div class="clearer"></div>
 
127
    </div>
 
128
    <div class="related">
 
129
      <h3>Navigation</h3>
 
130
      <ul>
 
131
        <li class="right" style="margin-right: 10px">
 
132
          <a href="../genindex.html" title="General Index"
 
133
             >index</a></li>
 
134
        <li class="right" >
 
135
          <a href="configuration.html" title="Configuration"
 
136
             >next</a> |</li>
 
137
        <li class="right" >
 
138
          <a href="general.html" title="General questions"
 
139
             >previous</a> |</li>
 
140
        <li><a href="../index.html">Varnish version 3.0.2 documentation</a> &raquo;</li>
 
141
          <li><a href="index.html" >Frequently asked questions</a> &raquo;</li> 
 
142
      </ul>
 
143
    </div>
 
144
    <div class="footer">
 
145
        &copy; Copyright 2010, Varnish Project.
 
146
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
 
147
    </div>
 
148
  </body>
 
149
</html>
 
 
b'\\ No newline at end of file'