github.com/krum110487/go-htaccess@v0.0.0-20240316004156-60641c8e7598/tests/data/apache_2_2_34/manual/dns-caveats.html.en (about)

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