bottleneck testcase based on rubbos
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / docs / manual / dns-caveats.html.en
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
4         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5               This file is generated from xml source: DO NOT EDIT
6         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7       -->
8 <title>Issues Regarding DNS and Apache - Apache HTTP Server</title>
9 <link href="./style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10 <link href="./style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11 <link href="./style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
12 <link href="./images/favicon.ico" rel="shortcut icon" /></head>
13 <body id="manual-page"><div id="page-header">
14 <p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p>
15 <p class="apache">Apache HTTP Server Version 2.0</p>
16 <img alt="" src="./images/feather.gif" /></div>
17 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="./images/left.gif" /></a></div>
18 <div id="path">
19 <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="./">Version 2.0</a></div><div id="page-content"><div id="preamble"><h1>Issues Regarding DNS and Apache</h1>
20 <div class="toplang">
21 <p><span>Available Languages: </span><a href="./en/dns-caveats.html" title="English">&nbsp;en&nbsp;</a> |
22 <a href="./es/dns-caveats.html" hreflang="es" rel="alternate" title="Español">&nbsp;es&nbsp;</a> |
23 <a href="./fr/dns-caveats.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a> |
24 <a href="./ja/dns-caveats.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
25 <a href="./ko/dns-caveats.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
26 <a href="./tr/dns-caveats.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
27 </div>
28
29     <p>This page could be summarized with the statement: don't
30     configure Apache in such a way that it relies on DNS resolution
31     for parsing of the configuration files. If Apache requires DNS
32     resolution to parse the configuration files then your server
33     may be subject to reliability problems (ie. it might not boot),
34     or denial and theft of service attacks (including users able
35     to steal hits from other users).</p>
36   </div>
37 <div id="quickview"><ul id="toc"><li><img alt="" src="./images/down.gif" /> <a href="#example">A Simple Example</a></li>
38 <li><img alt="" src="./images/down.gif" /> <a href="#denial">Denial of Service</a></li>
39 <li><img alt="" src="./images/down.gif" /> <a href="#main">The "main server" Address</a></li>
40 <li><img alt="" src="./images/down.gif" /> <a href="#tips">Tips to Avoid These Problems</a></li>
41 <li><img alt="" src="./images/down.gif" /> <a href="#appendix">Appendix: Future Directions</a></li>
42 </ul></div>
43 <div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
44 <div class="section">
45 <h2><a name="example" id="example">A Simple Example</a></h2>
46     
47
48     <div class="example"><p><code>
49       &lt;VirtualHost www.abc.dom&gt; <br />
50       ServerAdmin webgirl@abc.dom <br />
51       DocumentRoot /www/abc <br />
52       &lt;/VirtualHost&gt;
53     </code></p></div>
54
55     <p>In order for Apache to function properly, it absolutely needs
56     to have two pieces of information about each virtual host: the
57     <code class="directive"><a href="./mod/core.html#servername">ServerName</a></code> and at least one
58     IP address that the server will bind and respond to. The above
59     example does not include the IP address, so Apache must use DNS
60     to find the address of <code>www.abc.dom</code>. If for some
61     reason DNS is not available at the time your server is parsing
62     its config file, then this virtual host <strong>will not be
63     configured</strong>. It won't be able to respond to any hits
64     to this virtual host (prior to Apache version 1.2 the server
65     would not even boot).</p>
66
67     <p>Suppose that <code>www.abc.dom</code> has address 10.0.0.1.
68     Then consider this configuration snippet:</p>
69
70     <div class="example"><p><code>
71       &lt;VirtualHost 10.0.0.1&gt; <br />
72       ServerAdmin webgirl@abc.dom <br />
73       DocumentRoot /www/abc <br />
74       &lt;/VirtualHost&gt;
75     </code></p></div>
76
77     <p>This time Apache needs to use reverse DNS to find the
78     <code>ServerName</code> for this virtualhost. If that reverse
79     lookup fails then it will partially disable the virtualhost
80     (prior to Apache version 1.2 the server would not even boot).
81     If the virtual host is name-based then it will effectively be
82     totally disabled, but if it is IP-based then it will mostly
83     work. However, if Apache should ever have to generate a full
84     URL for the server which includes the server name, then it will
85     fail to generate a valid URL.</p>
86
87     <p>Here is a snippet that avoids both of these problems:</p>
88
89     <div class="example"><p><code>
90       &lt;VirtualHost 10.0.0.1&gt; <br />
91       ServerName www.abc.dom <br />
92       ServerAdmin webgirl@abc.dom <br />
93       DocumentRoot /www/abc <br />
94       &lt;/VirtualHost&gt;
95     </code></p></div>
96   </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
97 <div class="section">
98 <h2><a name="denial" id="denial">Denial of Service</a></h2>
99     
100
101     <p>There are (at least) two forms that denial of service
102     can come in. If you are running a version of Apache prior to
103     version 1.2 then your server will not even boot if one of the
104     two DNS lookups mentioned above fails for any of your virtual
105     hosts. In some cases this DNS lookup may not even be under your
106     control; for example, if <code>abc.dom</code> is one of your
107     customers and they control their own DNS, they can force your
108     (pre-1.2) server to fail while booting simply by deleting the
109     <code>www.abc.dom</code> record.</p>
110
111     <p>Another form is far more insidious. Consider this
112     configuration snippet:</p>
113
114     <div class="example"><p><code>
115       &lt;VirtualHost www.abc.dom&gt; <br />
116       &nbsp;&nbsp;ServerAdmin webgirl@abc.dom <br />
117       &nbsp;&nbsp;DocumentRoot /www/abc <br />
118       &lt;/VirtualHost&gt; <br />
119       <br />
120       &lt;VirtualHost www.def.dom&gt; <br />
121       &nbsp;&nbsp;ServerAdmin webguy@def.dom <br />
122       &nbsp;&nbsp;DocumentRoot /www/def <br />
123       &lt;/VirtualHost&gt;
124     </code></p></div>
125
126     <p>Suppose that you've assigned 10.0.0.1 to
127     <code>www.abc.dom</code> and 10.0.0.2 to
128     <code>www.def.dom</code>. Furthermore, suppose that
129     <code>def.dom</code> has control of their own DNS. With this
130     config you have put <code>def.dom</code> into a position where
131     they can steal all traffic destined to <code>abc.dom</code>. To
132     do so, all they have to do is set <code>www.def.dom</code> to
133     10.0.0.1. Since they control their own DNS you can't stop them
134     from pointing the <code>www.def.dom</code> record wherever they
135     wish.</p>
136
137     <p>Requests coming in to 10.0.0.1 (including all those where
138     users typed in URLs of the form
139     <code>http://www.abc.dom/whatever</code>) will all be served by
140     the <code>def.dom</code> virtual host. To better understand why
141     this happens requires a more in-depth discussion of how Apache
142     matches up incoming requests with the virtual host that will
143     serve it. A rough document describing this <a href="vhosts/details.html">is available</a>.</p>
144   </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
145 <div class="section">
146 <h2><a name="main" id="main">The "main server" Address</a></h2>
147     
148
149     <p>The addition of <a href="vhosts/name-based.html">name-based
150     virtual host support</a> in Apache 1.1 requires Apache to know
151     the IP address(es) of the host that <code class="program"><a href="./programs/httpd.html">httpd</a></code> is running
152     on. To get this address it uses either the global 
153     <code class="directive"><a href="./mod/core.html#servername">ServerName</a></code>
154     (if present) or calls the C function <code>gethostname</code>
155     (which should return the same as typing "hostname" at the
156     command prompt). Then it performs a DNS lookup on this address.
157     At present there is no way to avoid this lookup.</p>
158
159     <p>If you fear that this lookup might fail because your DNS
160     server is down then you can insert the hostname in
161     <code>/etc/hosts</code> (where you probably already have it so
162     that the machine can boot properly). Then ensure that your
163     machine is configured to use <code>/etc/hosts</code> in the
164     event that DNS fails. Depending on what OS you are using this
165     might be accomplished by editing <code>/etc/resolv.conf</code>,
166     or maybe <code>/etc/nsswitch.conf</code>.</p>
167
168     <p>If your server doesn't have to perform DNS for any other
169     reason then you might be able to get away with running Apache
170     with the <code>HOSTRESORDER</code> environment variable set to
171     "local". This all depends on what OS and resolver libraries you
172     are using. It also affects CGIs unless you use 
173     <code class="module"><a href="./mod/mod_env.html">mod_env</a></code> to control the environment. It's best 
174     to consult the man pages or FAQs for your OS.</p>
175   </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
176 <div class="section">
177 <h2><a name="tips" id="tips">Tips to Avoid These Problems</a></h2>
178     
179
180     <ul>
181       <li>
182         use IP addresses in 
183         <code class="directive"><a href="./mod/core.html#virtualhost">VirtualHost</a></code>
184       </li>
185
186       <li>
187         use IP addresses in 
188         <code class="directive"><a href="./mod/mpm_common.html#listen">Listen</a></code>
189       </li>
190
191       <li>
192         ensure all virtual hosts have an explicit
193         <code class="directive"><a href="./mod/core.html#servername">ServerName</a></code>
194       </li>
195
196       <li>create a <code>&lt;VirtualHost _default_:*&gt;</code>
197       server that has no pages to serve</li>
198     </ul>
199   </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
200 <div class="section">
201 <h2><a name="appendix" id="appendix">Appendix: Future Directions</a></h2>
202     
203
204     <p>The situation regarding DNS is highly undesirable. For
205     Apache 1.2 we've attempted to make the server at least continue
206     booting in the event of failed DNS, but it might not be the
207     best we can do. In any event, requiring the use of explicit IP
208     addresses in configuration files is highly undesirable in
209     today's Internet where renumbering is a necessity.</p>
210
211     <p>A possible work around to the theft of service attack
212     described above would be to perform a reverse DNS lookup on the
213     IP address returned by the forward lookup and compare the two
214     names -- in the event of a mismatch, the virtualhost would be
215     disabled. This would require reverse DNS to be configured
216     properly (which is something that most admins are familiar with
217     because of the common use of "double-reverse" DNS lookups by
218     FTP servers and TCP wrappers).</p>
219
220     <p>In any event, it doesn't seem possible to reliably boot a
221     virtual-hosted web server when DNS has failed unless IP
222     addresses are used. Partial solutions such as disabling
223     portions of the configuration might be worse than not booting
224     at all depending on what the webserver is supposed to
225     accomplish.</p>
226
227     <p>As HTTP/1.1 is deployed and browsers and proxies start
228     issuing the <code>Host</code> header it will become possible to
229     avoid the use of IP-based virtual hosts entirely. In this case,
230     a webserver has no requirement to do DNS lookups during
231     configuration. But as of March 1997 these features have not
232     been deployed widely enough to be put into use on critical
233     webservers.</p>
234   </div></div>
235 <div class="bottomlang">
236 <p><span>Available Languages: </span><a href="./en/dns-caveats.html" title="English">&nbsp;en&nbsp;</a> |
237 <a href="./es/dns-caveats.html" hreflang="es" rel="alternate" title="Español">&nbsp;es&nbsp;</a> |
238 <a href="./fr/dns-caveats.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a> |
239 <a href="./ja/dns-caveats.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
240 <a href="./ko/dns-caveats.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
241 <a href="./tr/dns-caveats.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
242 </div><div id="footer">
243 <p class="apache">Copyright 2009 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
244 <p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p></div>
245 </body></html>