<?xml version="1.0"?>
<?rfc compact="yes" ?>
<?rfc symrefs="yes" ?>
<?rfc sortrefs="yes" ?>
<?rfc toc="yes" ?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY rfc1034 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.1034.xml'>
<!ENTITY rfc1035 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.1035.xml'>
<!ENTITY rfc3986 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.3986.xml'>
<!ENTITY rfc2119 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml'>
<!ENTITY rfc2782 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.2782.xml'>
]>
<rfc ipr="pre5378Trust200902" docName="draft-andrews-http-srv-02" >
  <front>
    <title abbrev="HTTP-SRV">Use of SRV records in conjuction with HTTP and URIs"</title>
    <author initials="M." surname="Andrews" fullname="M. Andrews">
      <organization abbrev="ISC">Internet Systems Consortium</organization>
      <address>
        <postal>
          <street>950 Charter Street</street>
          <city>Redwood City</city>
          <region>CA</region>
          <code>94063</code>
          <country>US</country>
        </postal>
        <email>marka@isc.org</email>
      </address>
    </author>
    <author initials="T." surname="Kottelin" fullname="T. Kottelin">
    <address>
      <postal>
	<street>Laivalahden puistotie 10 C 37</street>
	<city>Helsinki</city>
	<code>FIN-00810</code>
	<country>Finland</country>
      </postal>
      <email>thor@anta.net</email>
      </address>
    </author>
    <date month="May" year="2014" />
    <abstract>
      <t>
	The combined use of SRV records for HTTP along with URIs is not
	as straight forward as it would appear at first glance.  This
	document looks at the issues involved and recommends solutions.
      </t>
    </abstract>
  </front>
  <middle>
    <section toc="yes" anchor="intro" title="Introduction">
      <t>
	Many of todays HTTP sites are virtual, that is they are
	hosted on a machine that is not known by the name the HTTP
	site is known by.  This leads to the problem of how to
	rationally give these HTTP sites IP addresses.  This has
	traditionally been done by using CNAMES <xref target="RFC1034"
	/> <xref target="RFC1035" /> or by using explicit IP address
	records where CNAMES are illegal due to restrictions in the
	DNS.
      </t> <t>
	Both of these solutions have undesired side effects.  CNAMES
	are not protocol specific.  Using IP address records is a
	logistic nightmare for large servers with many virtual
	sites.  This is becoming a bigger problem as companies move
	away from identifying their HTTP site with a "www" prefix
	and just use their delegated domain name, e.g.
	"http://example.com/".
      </t> <t>
	Using SRV <xref target="RFC2782" /> records would seem to
	be a natural solution to this problem in that they are
	protocol specific and will work where CNAMES are illegal
	in the DNS.
      </t> <t>
	There are problems with doing this without thought however
	in that URIs <xref target="RFC3986" /> can specify a port
	and SRV records do specify a port.  When this occurs which
	one do you honour?
      </t> <t>
	In addition to this SRV records provide for load balancing.
	For most protocols this is straight forward as there will
	only be a single connection made.  For HTTP however there
	are often many connections made in a session.  Should each
	of these individual connections be load balanced or should
	the load balancing be on a per session basis?
      </t> <t>
	The key words "MUST", "REQUIRED", "SHOULD", "RECOMMENDED",
	"NOT RECOMMENDED", and "MAY" in this document are to be
	interpreted as described in <xref target="RFC2119" />.
      </t>
    </section>

    <section toc="yes" anchor="implicit" title="URIs without an explicit port specification">
      <t>
	If the URI does not explicitly specify a port to connect
	to, i.e.  the URI does not contain a ":&lt;port&gt;" part,
	there is no port conflict.  In this case a client MUST
	follow the logic specified in <xref target="RFC2782" />,
	including the server selection mechanism provided by the
	priority and weight fields.  If SRV records do not exist
	then the client MUST fall back to looking for IP address
	records.
      </t> <t>
	Once a server is selected it SHOULD be continued to be used
	for the rest of the session if possible after an initial
	connection is made.  If a server has multiple addresses the
	client SHOULD continue to use the same address while possible
	taking into consideration ttl values on address records.
	If connections to this address fail it SHOULD try the other
	addresses for the server first before attempting other
	servers.
      </t> <t>
	The use of a SRV record does not affect the contents of the
	"Host:" field of the HTTP transaction.  Its only effect is
	to potentially change the address and port the client
	connects to.  All other parts of the HTTP transaction are
	not affected by the presence of a SRV record.
      </t> <t>
	Examples:
      </t> <t>
	Single SRV record:
      </t>

      <figure>
	<artwork>
URI:     http://example.com/
SRV RR:  _http._tcp.example.com. SRV   10 0 8080 host1.example.com.
A RRs:   example.com.            A     10.0.0.2
         host1.example.com.      A     10.0.1.1
	</artwork>
      </figure>
      <t>
	Connect to:  10.0.1.1 port 8080
      </t> <t>
	Multiple SRV records:
      </t>

      <figure>
	<artwork>
URI:      http://example.com/
SRV RRs:  _http._tcp.example.com. SRV   10 1 8080 host1.example.com.
          _http._tcp.example.com. SRV   10 3 8080 host2.example.com.
          _http._tcp.example.com. SRV   20 0 8080 host3.example.com.
A RRs:    example.com.            A     10.0.0.4
          host1.example.com.      A     10.0.1.2
          host2.example.com.      A     10.0.2.2
          host3.example.com.      AAAA  1080::8:800:200C:417A
	</artwork>
      </figure>

      <t>
	Connect to: 10.0.1.2 port 8080 or 10.0.2.2 port 8080 if
	either is available (the probability of being selected
	should be 25% for 10.0.1.2 port 8080, and 75% for 10.0.2.2
	port 8080); otherwise, try 1080::8:800:200C:417A port 8080.
      </t>
    </section>

    <section toc="yes" anchor="explicit" title="URIs with a explicit port specification">
      <t>
	If the URI does explicitly specify a port, other than the
	default port, to connect to then there is a potential
	conflict in the port specification between the URI and the
	SRV records, and the SRV record is ignored.  In this case
	the user agent MUST query for address records for the host
	name in the URI (instead of SRV records).
      </t> <t>
	If the server has multiple addresses the client SHOULD
	continue to use the same address while possible taking into
	consideration ttl values on address records.
      </t> <t>
	Note <xref target="RFC3986" />, Section 6.2.3. Scheme-Based
	Normalization states that URIs with a port value equal to
	the default port (80) are identical to those with no port
	or a empty port.
      </t> <t>
	Examples:
      </t> <t>
	Default port specified:
      </t>

      <figure>
	<artwork>
URI:      http://example.com:80/
SRV RR:   _http._tcp.example.com. SRV   10 1 8080 host2.example.com.
A RRs:    example.com.            A     10.0.0.1
          host2.example.com.      A     10.0.2.2
	</artwork>
      </figure>

      <t>
	Connect to: 10.0.0.2 port 8080
      </t> <t>
	Non-default port specified:
      </t>

      <figure>
	<artwork>
URI:      http://example.com:8080/
SRV RR:   _http._tcp.example.com. SRV   10 1 80 host2.example.com.
CNAME RR: example.com.            CNAME host1.example.com.
A RRs:    host1.example.com.      A     10.0.0.1
          host2.example.com.      AAAA  1080::8:800:200C:417A
	</artwork>
      </figure>

      <t>
	Connect to: 10.0.0.1 port 8080
      </t>
   </section>

   <section toc="yes" anchor="transition" title="Transitioning Considerations" >
      <t>
	When transitioning from using a non-SRV solution to using
	a SRV based solution old, non-SRV aware, clients will
	continue to look for address records.  It may be necessary
	to use redirection at the HTTP layer to direct these clients
	to the new servers if the SRV records point to a different
	&lt;address, port&gt; tuple.
      </t> <t>
	It will also be necessary to continue to provide the existing
	address / CNAME records until there is a significant
	percentage of SRV aware clients.  Experience has shown that
	this should be within one to two years of the introduction
	of the first SRV aware client.
      </t> <t>
	In cases where you are just trying to replace the A or CNAME
	record referring to a service providers machine with a SRV
	record the following should suffice.
      </t> <t>
	The service provider is hosting the service on machine.example.net
	and you are example.com.
      </t>

      <figure>
	<artwork>
example.com.            A   &lt;IP address of machine.example.net&gt;
_http._tcp.example.com. SRV 0 0 80 machine.example.net.
	</artwork>
      </figure>
    </section>

    <section toc="yes" anchor="security" title="Security Considerations" >
      <t>
	The authors believe the algorithm described in this document
	to not cause any new security problems.  However care should
	be taken as SRV and non-SRV aware clients may be directed
	to different locations.
      </t>
    </section>

    <section toc="yes" anchor="iana" title="IANA Considerations" >
      <t>
	A well known label has to be allocated for the first label
	of the http SRV record.  This document has used "_http".
      </t>
    </section>
  </middle>

  <back>
    <references title="Normative References">
      &rfc1034;
      &rfc1035;
      &rfc2119;
      &rfc2782;
      &rfc3986;
    </references>
  </back>
</rfc>
