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

« back to all changes in this revision

Viewing changes to bin/varnishd/default_vcl.h

  • Committer: Bazaar Package Importer
  • Author(s): Stig Sandbeck Mathisen
  • Date: 2011-03-21 10:16:07 UTC
  • mfrom: (24.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20110321101607-528fzl583fqanas5
Tags: 2.1.5-2
ReleaseĀ forĀ unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 "/*-\n"
2
 
 " * Copyright (c) 2006 Verdens Gang AS\n"
3
 
 " * Copyright (c) 2006-2009 Linpro AS\n"
4
 
 " * All rights reserved.\n"
5
 
 " *\n"
6
 
 " * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n"
7
 
 " *\n"
8
 
 " * Redistribution and use in source and binary forms, with or without\n"
9
 
 " * modification, are permitted provided that the following conditions\n"
10
 
 " * are met:\n"
11
 
 " * 1. Redistributions of source code must retain the above copyright\n"
12
 
 " *    notice, this list of conditions and the following disclaimer.\n"
13
 
 " * 2. Redistributions in binary form must reproduce the above copyright\n"
14
 
 " *    notice, this list of conditions and the following disclaimer in the\n"
15
 
 " *    documentation and/or other materials provided with the distribution.\n"
16
 
 " *\n"
17
 
 " * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n"
18
 
 " * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n"
19
 
 " * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n"
20
 
 " * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE\n"
21
 
 " * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n"
22
 
 " * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n"
23
 
 " * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR \n"
24
 
 " * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n"
25
 
 " * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n"
26
 
 " * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n"
27
 
 " * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
28
 
 " *\n"
29
 
 " * $Id: default.vcl 5026 2010-07-06 12:06:03Z tfheen $\n"
30
 
 " *\n"
31
 
 " * The default VCL code.\n"
32
 
 " *\n"
33
 
 " * NB! You do NOT need to copy & paste all of these functions into your\n"
34
 
 " * own vcl code, if you do not provide a definition of one of these\n"
35
 
 " * functions, the compiler will automatically fall back to the default\n"
36
 
 " * code from this file.\n"
37
 
 " *\n"
38
 
 " * This code will be prefixed with a backend declaration built from the\n"
39
 
 " * -b argument.\n"
40
 
 " */\n"
41
 
 "\n"
42
 
 "sub vcl_recv {\n"
43
 
 "    if (req.http.x-forwarded-for) {\n"
44
 
 "      set req.http.X-Forwarded-For =\n"
45
 
 "          req.http.X-Forwarded-For \", \" client.ip;\n"
46
 
 "    } else {\n"
47
 
 "      set req.http.X-Forwarded-For = client.ip;\n"
48
 
 "    }\n"
49
 
 "    if (req.request != \"GET\" &&\n"
50
 
 "      req.request != \"HEAD\" &&\n"
51
 
 "      req.request != \"PUT\" &&\n"
52
 
 "      req.request != \"POST\" &&\n"
53
 
 "      req.request != \"TRACE\" &&\n"
54
 
 "      req.request != \"OPTIONS\" &&\n"
55
 
 "      req.request != \"DELETE\") {\n"
56
 
 "        /* Non-RFC2616 or CONNECT which is weird. */\n"
57
 
 "        return (pipe);\n"
58
 
 "    }\n"
59
 
 "    if (req.request != \"GET\" && req.request != \"HEAD\") {\n"
60
 
 "        /* We only deal with GET and HEAD by default */\n"
61
 
 "        return (pass);\n"
62
 
 "    }\n"
63
 
 "    if (req.http.Authorization || req.http.Cookie) {\n"
64
 
 "        /* Not cacheable by default */\n"
65
 
 "        return (pass);\n"
66
 
 "    }\n"
67
 
 "    return (lookup);\n"
68
 
 "}\n"
69
 
 "\n"
70
 
 "sub vcl_pipe {\n"
71
 
 "    # Note that only the first request to the backend will have\n"
72
 
 "    # X-Forwarded-For set.  If you use X-Forwarded-For and want to\n"
73
 
 "    # have it set for all requests, make sure to have:\n"
74
 
 "    # set req.http.connection = \"close\";\n"
75
 
 "    # here.  It is not set by default as it might break some broken web\n"
76
 
 "    # applications, like IIS with NTLM authentication.\n"
77
 
 "    return (pipe);\n"
78
 
 "}\n"
79
 
 "\n"
80
 
 "sub vcl_pass {\n"
81
 
 "    return (pass);\n"
82
 
 "}\n"
83
 
 "\n"
84
 
 "sub vcl_hash {\n"
85
 
 "    set req.hash += req.url;\n"
86
 
 "    if (req.http.host) {\n"
87
 
 "        set req.hash += req.http.host;\n"
88
 
 "    } else {\n"
89
 
 "        set req.hash += server.ip;\n"
90
 
 "    }\n"
91
 
 "    return (hash);\n"
92
 
 "}\n"
93
 
 "\n"
94
 
 "sub vcl_hit {\n"
95
 
 "    if (!obj.cacheable) {\n"
96
 
 "        return (pass);\n"
97
 
 "    }\n"
98
 
 "    return (deliver);\n"
99
 
 "}\n"
100
 
 "\n"
101
 
 "sub vcl_miss {\n"
102
 
 "    return (fetch);\n"
103
 
 "}\n"
104
 
 "\n"
105
 
 "sub vcl_fetch {\n"
106
 
 "    if (!beresp.cacheable) {\n"
107
 
 "        return (pass);\n"
108
 
 "    }\n"
109
 
 "    if (beresp.http.Set-Cookie) {\n"
110
 
 "        return (pass);\n"
111
 
 "    }\n"
112
 
 "    return (deliver);\n"
113
 
 "}\n"
114
 
 "\n"
115
 
 "sub vcl_deliver {\n"
116
 
 "    return (deliver);\n"
117
 
 "}\n"
118
 
 "\n"
119
 
 "sub vcl_error {\n"
120
 
 "    set obj.http.Content-Type = \"text/html; charset=utf-8\";\n"
121
 
 "    synthetic {\"\n"
122
 
 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
123
 
 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n"
124
 
 " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
125
 
 "<html>\n"
126
 
 "  <head>\n"
127
 
 "    <title>\"} obj.status \" \" obj.response {\"</title>\n"
128
 
 "  </head>\n"
129
 
 "  <body>\n"
130
 
 "    <h1>Error \"} obj.status \" \" obj.response {\"</h1>\n"
131
 
 "    <p>\"} obj.response {\"</p>\n"
132
 
 "    <h3>Guru Meditation:</h3>\n"
133
 
 "    <p>XID: \"} req.xid {\"</p>\n"
134
 
 "    <hr>\n"
135
 
 "    <p>Varnish cache server</p>\n"
136
 
 "  </body>\n"
137
 
 "</html>\n"
138
 
 "\"};\n"
139
 
 "    return (deliver);\n"
140
 
 "}\n"