<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="lib/rfc2629.xslt"?>
<?rfc toc="yes" ?>
<?rfc symrefs="yes" ?>
<?rfc sortrefs="yes" ?>
<?rfc compact="yes"?>
<?rfc subcompact="no" ?>
<?rfc linkmailto="no" ?>
<?rfc editing="no" ?>
<?rfc comments="yes" ?>
<?rfc inline="yes"?>
<?rfc rfcedstyle="yes"?>
<?rfc-ext allow-markup-in-artwork="yes" ?>
<?rfc-ext include-index="no" ?>
<?rfc-ext html-pretty-print="prettyprint https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"?>

<!DOCTYPE rfc [
  <!ENTITY MAY "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>MAY</bcp14>">
  <!ENTITY MUST "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>MUST</bcp14>">
  <!ENTITY MUST-NOT "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>MUST NOT</bcp14>">
  <!ENTITY OPTIONAL "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>OPTIONAL</bcp14>">
  <!ENTITY RECOMMENDED "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>RECOMMENDED</bcp14>">
  <!ENTITY REQUIRED "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>REQUIRED</bcp14>">
  <!ENTITY SHALL "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHALL</bcp14>">
  <!ENTITY SHALL-NOT "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHALL NOT</bcp14>">
  <!ENTITY SHOULD "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHOULD</bcp14>">
  <!ENTITY SHOULD-NOT "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHOULD NOT</bcp14>">
  <!ENTITY mdash "&#8212;">
]>

<rfc ipr="trust200902"
     category="std"
     number="7838"
     x:maturity-level="proposed"
     xmlns:x="http://purl.org/net/xml2rfc/ext">
  <front>
    <title>HTTP Alternative Services</title>

    <author initials="M." surname="Nottingham" fullname="Mark Nottingham">
      <organization>Akamai</organization>
      <address>
        <email>mnot@mnot.net</email>
        <uri>https://www.mnot.net/</uri>
      </address>
    </author>

    <author initials="P." surname="McManus" fullname="Patrick McManus">
      <organization>Mozilla</organization>
      <address>
        <email>mcmanus@ducksong.com</email>
        <uri>https://mozillians.org/u/pmcmanus/</uri>
      </address>
    </author>

    <author initials="J. F." surname="Reschke" fullname="Julian F. Reschke">
      <organization abbrev="greenbytes">greenbytes GmbH</organization>
      <address>
        <email>julian.reschke@greenbytes.de</email>
        <uri>https://greenbytes.de/tech/webdav/</uri>
      </address>
    </author>

    <date year="2016" month="4"/>
    <area>Applications and Real-Time</area>
    <workgroup>HTTP</workgroup>
    <keyword>HTTP</keyword>
    <keyword>ALPN</keyword>
    <keyword>Alternative Services</keyword>

    <abstract>
      <t>
        This document specifies "Alternative Services" for HTTP, which allow an
        origin's resources to be authoritatively available at a separate network
        location, possibly accessed with a different protocol configuration.</t>
    </abstract>

  </front>
  <middle>

<section anchor="introduction" title="Introduction">
<t>
   HTTP <xref target="RFC7230"/> conflates the identification of
   resources with their location. In other words, "http://" and "https://" URIs are
   used to both name and find things to interact with.
</t>
<t>
   In some cases, it is desirable to separate identification and location in HTTP; keeping the same
   identifier for a resource, but interacting with it at a different location on the network.
</t>
<t>For example:
  <list style="symbols">
    <t>
       An origin server might wish to redirect a client to a different server
       when it is under load, or it has found a server in a location that is
       more local to the client.
    </t>
    <t>
       An origin server might wish to offer access to its resources using a new
       protocol, such as HTTP/2 <xref target="RFC7540"/>, or one using improved
       security, such as Transport Layer Security (TLS) <xref target="RFC5246"/>.
    </t>
    <t>
       An origin server might wish to segment its clients into groups of
       capabilities, such as those supporting Server Name Indication (SNI) 
       (<xref target="RFC6066" x:sec="3" x:fmt="of"/>), for operational purposes.
    </t>
  </list>
</t>
<t>
   This specification defines a new concept in HTTP, "Alternative Services",
   that allows an origin server to nominate additional means of interacting with it on
   the network. It defines a general framework for this in <xref
   target="alternative"/>, along with specific mechanisms for advertising their
   existence using HTTP header fields (<xref target="alt-svc"/>) or HTTP/2
   frames (<xref target="frame"/>), plus a way to indicate that an alternative
   service was used (<xref target="indicator"/>).
</t>
<t>
   It also endorses the status code 421 (Misdirected Request) (<xref target="status"/>)
   that origin servers or their nominated alternatives can use to indicate that they
   are not authoritative for a given origin, in cases where the wrong location is used.
</t>

<section title="Notational Conventions" anchor="notational-conventions">
<t>
  The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
  "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
  interpreted as described in <xref target="RFC2119"/>.
</t>
<t anchor="imported.abnf">
  <x:anchor-alias value="OWS"/>
  <x:anchor-alias value="delta-seconds"/>
  <x:anchor-alias value="port"/>
  <x:anchor-alias value="quoted-string"/>
  <x:anchor-alias value="token"/>
  <x:anchor-alias value="uri-host"/>
  This document uses the Augmented BNF defined in <xref target="RFC5234"/> and
  updated by <xref target="RFC7405"/>
  along with the "#rule" extension defined in <xref target="RFC7230" x:rel="#abnf.extension" x:fmt="of"/>.
  The rules below are defined in <xref target="RFC5234"/>, <xref target="RFC7230"/>, and <xref target="RFC7234"/>:
</t>
<figure><artwork type="abnf2616">
OWS           = &lt;OWS, see <xref target="RFC7230" x:rel="#whitespace"/>&gt;
delta-seconds = &lt;delta-seconds; see <xref target="RFC7234" x:rel="#delta-seconds"/>&gt;
port          = &lt;port, see <xref target="RFC7230" x:rel="#uri"/>&gt;
quoted-string = &lt;quoted-string, see <xref target="RFC7230" x:rel="#field.components"/>&gt;
token         = &lt;token, see <xref target="RFC7230" x:rel="#field.components"/>&gt;
uri-host      = &lt;uri-host, see <xref target="RFC7230" x:rel="#uri"/>&gt;
</artwork></figure>
</section>

    </section>

<section title="Alternative Services Concepts" anchor="alternative">
<t>
   This specification defines a new concept in HTTP, the "<x:dfn>Alternative Service</x:dfn>".
   When an origin <xref target="RFC6454"/> has resources that are accessible through a
   different protocol/host/port combination, it is said to have an alternative
   service available.
</t>
<t>
   An alternative service can be used to interact with the resources on an origin
   server at a separate location on the network, possibly using a different
   protocol configuration. Alternative services are considered authoritative for
   an origin's resources, in the sense of <xref target="RFC7230" x:rel="#establishing.authority" x:fmt=","/>.
</t>
<figure>
  <preamble>For example, an origin:</preamble>
  <artwork type="example">
("http", "www.example.com", "80")
</artwork>
</figure>
<figure>
<preamble>might declare that its resources are also accessible at the alternative service:</preamble>
<artwork type="example">
("h2", "new.example.com", "81")
</artwork>
</figure>
<t>
   By their nature, alternative services are explicitly at the granularity of an
   origin; they cannot be selectively applied to resources within an origin.
</t>
<t>
   Alternative services do not replace or change the origin for any given resource;
   in general, they are not visible to the software "above" the access mechanism.
   The alternative service is essentially alternative routing information that can
   also be used to reach the origin in the same way that DNS CNAME or SRV records
   define routing information at the name resolution level. Each origin maps to a
   set of these routes &mdash; the default route is derived from the origin itself and the
   other routes are introduced based on alternative-service information.
</t>
<t>
   Furthermore, it is important to note that the first member of an alternative
   service tuple is different from the "scheme" component of an origin; it is more
   specific, identifying not only the major version of the protocol being used,
   but potentially the communication options for that protocol as well.
</t>
<t>
   This means that clients using an alternative service can change the host, port,
   and protocol that they are using to fetch resources, but these changes &MUST-NOT;
   be propagated to the application that is using HTTP; from that standpoint, the
   URI being accessed and all information derived from it (scheme, host, and port) are
   the same as before.
</t>
<t>
   Importantly, this includes its security context; in particular, when TLS
   <xref target="RFC5246"/> is used to authenticate, the alternative service will need to present a certificate
   for the origin's host name, not that of the alternative. Likewise, the Host
   header field (<xref target="RFC7230" x:fmt="," x:rel="#header.host"/>) is
   still derived from the origin, not the alternative service (just as it would
   if a CNAME were being used).
</t>
<t>
   The changes &MAY;, however, be made visible in debugging tools, consoles, etc.
</t>
<t>
   Formally, an alternative service is identified by the combination of:
  <list style="symbols">
    <t>An Application Layer Protocol Negotiation (ALPN) protocol name, as per
    <xref target="RFC7301"/></t>
    <t>A host, as per <xref target="RFC3986" x:fmt="," x:sec="3.2.2"/></t>
    <t>A port, as per <xref target="RFC3986" x:fmt="," x:sec="3.2.3"/></t>
  </list>
</t>
<t>
   The ALPN protocol name is used to identify the application protocol or
   suite of protocols used by the alternative service.  Note that for the
   purpose of this specification, an ALPN protocol name implicitly
   includes TLS in the suite of protocols it identifies, unless specified
   otherwise in its definition. In particular, the ALPN name "http/1.1",
   registered by <xref x:sec="6" x:fmt="of" target="RFC7301"/>, identifies
   HTTP/1.1 over TLS.
</t>
<t>
   Additionally, each alternative service &MUST; have a freshness lifetime,
   expressed in seconds (see <xref target="caching"/>).
</t>
<t>
   There are many ways that a client could discover the alternative service(s)
   associated with an origin.  This document describes two such mechanisms:
   the "Alt-Svc" HTTP header field (<xref target="alt-svc"/>) and the "ALTSVC" HTTP/2 frame type
   (<xref target="frame"/>).
</t>
<t>
   The remainder of this section describes requirements that are common to alternative
   services, regardless of how they are discovered.
</t>

<section title="Host Authentication" anchor="host_auth">
<t>
   Clients &MUST; have reasonable assurances that the alternative service is under control of and
   valid for the whole origin. This mitigates the attack described in <xref
   target="host_security"/>.
</t>
<t>
   For the purposes of this document, "reasonable assurances" can be established through use of a
   TLS-based protocol with the certificate checks defined in <xref target="RFC2818"/>. Clients
   &MAY; impose additional criteria for establishing reasonable assurances.
</t>
<t>
   For example, if the origin's host is "www.example.com" and an alternative is offered on
   "other.example.com" with the "h2" protocol, and the certificate offered is valid for
   "www.example.com", the client can use the alternative. However, if either is offered with the
   "h2c" protocol, the client cannot use it, because there is no mechanism (at the time of the
   publication of this specification) in that protocol to establish the relationship between the
   origin and the alternative.
</t>
</section>

<section title="Alternative Service Caching" anchor="caching">
<t>
   Mechanisms for discovering alternative services also associate a freshness
   lifetime with them; for example, the Alt-Svc header field uses the "ma"
   parameter.
</t>
<t>
   Clients can choose to use an alternative service instead of the origin at any
   time when it is considered fresh; see <xref target="switching"/> for specific
   recommendations.
</t>
<t>
   Clients with existing connections to an alternative service do not need to
   stop using it when its freshness lifetime ends; the caching
   mechanism is intended for limiting how long an alternative service can be used
   for establishing new connections, not limiting the use of existing ones.
</t>
<t>
   Alternative services are fully authoritative for the origin in question, including
   the ability to clear or update cached alternative service entries, extend freshness
   lifetimes, and any other authority the origin server would have.
</t>
<t>
   When alternative services are used to send a client to the most optimal server, a change in
   network configuration can result in cached values becoming suboptimal. Therefore, clients &SHOULD;
   remove from cache all alternative services that lack the "persist" flag with the value "1" when
   they detect such a change, when information about network state is available. 
</t>
</section>

<section title="Requiring Server Name Indication" anchor="requiring-server-name-indication">
<t>
   A client &MUST-NOT; use a TLS-based alternative service unless the client
   supports TLS Server Name Indication (SNI). This supports the conservation of
   IP addresses on the alternative service host.
</t>
<t>
   Note that the SNI information provided in TLS by the client will be that of the origin, not the
   alternative (as will the Host HTTP header field value).
</t>
</section>

<section title="Using Alternative Services" anchor="switching">
<t>
   By their nature, alternative services are &OPTIONAL;: clients do not need to
   use them. However, it is advantageous for clients to behave in a predictable
   way when alternative services are used by servers, to aid in purposes like load balancing.
</t>
<t>
   Therefore, if a client supporting this specification becomes aware of an alternative service,
   the client &SHOULD; use that alternative service for all requests to the associated origin as
   soon as it is available, provided the alternative service information is fresh (<xref
   target="caching"/>) and the security properties of the alternative service protocol are
   desirable, as compared to the existing connection. A viable alternative service is then treated
   in every way as the origin; this includes the ability to advertise alternative services.
</t>
<t>
   If a client becomes aware of multiple alternative services, it chooses
   the most suitable according to its own criteria, keeping security
   properties in mind. For example, an origin might advertise multiple
   alternative services to notify clients of support for multiple versions of
   HTTP.
</t>
<t>
   A client configured to use a proxy for a given request &SHOULD-NOT;
   directly connect to an alternative service for this request, but instead route it
   through that proxy.
</t>
<t>
   When a client uses an alternative service for a request, it can indicate
   this to the server using the  Alt-Used header field (<xref
      target="indicator"/>).
</t>
<t>
   The client does not need to block requests on any existing connection; it can be
   used until the alternative connection is established. However, if the security
   properties of the existing connection are weak (for example, cleartext HTTP/1.1), then
   it might make sense to block until the new connection is fully available in
   order to avoid information leakage.
</t>
<t>
   Furthermore, if the connection to the alternative service fails or is unresponsive, the client
   &MAY; fall back to using the origin or another alternative service. Note, however, that this
   could be the basis of a downgrade attack, thus losing any enhanced security properties of the
   alternative service.  If the connection to the alternative service does not negotiate the
   expected protocol (for example, ALPN fails to negotiate h2, or an Upgrade request to h2c is
   not accepted), the connection to the alternative service &MUST; be considered to have failed.
</t>
</section>
</section>

<section title="The Alt-Svc HTTP Header Field" anchor="alt-svc">
<t>
   An HTTP(S) origin server can advertise the availability of alternative services
   to clients by adding an Alt-Svc header field to responses.
</t>
<figure>
  <artwork type="abnf2616">
Alt-Svc       = clear / 1#alt-value
clear         = %s"clear"; "clear", case-sensitive
alt-value     = alternative *( OWS ";" OWS parameter )
alternative   = protocol-id "=" alt-authority
protocol-id   = <x:ref>token</x:ref> ; percent-encoded ALPN protocol name
alt-authority = <x:ref>quoted-string</x:ref> ; containing [ <x:ref>uri-host</x:ref> ] ":" <x:ref>port</x:ref>
parameter     = <x:ref>token</x:ref> "=" ( <x:ref>token</x:ref> / <x:ref>quoted-string</x:ref> )
</artwork>
</figure>
<t>
   The field value consists either of a list of values, each of which indicates one
   alternative service, or the keyword "clear".
</t>
<t>
   A field value containing the special value "clear" indicates that the
   origin requests all alternatives for that origin to be invalidated (including
   those specified in the same response, in case of an invalid reply containing
   both "clear" and alternative services).
</t>
<t>
   ALPN protocol names are octet sequences with no
   additional constraints on format.<!-- besides length?-->
   Octets not allowed in tokens (<xref target="RFC7230" x:fmt="," x:rel="#field.components"/>)
   &MUST; be percent-encoded as per <xref target="RFC3986" x:fmt="of" x:sec="2.1"/>.
   Consequently, the octet representing the percent character "%" (hex 25) &MUST;
   be percent-encoded as well.
</t>
<t>
   In order to have precisely one way to represent any ALPN protocol name, the following
   additional constraints apply:
   <list style="numbers">
    <t>
      Octets in the ALPN protocol name &MUST-NOT; be percent-encoded if they are valid
      token characters except "%", and
    </t>
    <t>
      When using percent-encoding, uppercase hex digits &MUST; be used.
    </t>
   </list>
</t>
<t>
  With these constraints, recipients can apply simple string comparison to
  match protocol identifiers.
</t>
<t>
  The "alt-authority" component consists of an &OPTIONAL; uri-host
  ("host" in <xref target="RFC3986" x:fmt="of" x:sec="3.2.2"/>), a colon (":"),
  and a port number.
</t>
<figure>
  <preamble>For example:</preamble>
   <artwork type="example">
Alt-Svc: h2=":8000"
</artwork>
<postamble>
   This indicates the "h2" protocol (<xref target="RFC7540"/>) on the same
   host using the indicated port 8000.
</postamble>
</figure>
<figure>
  <preamble>An example involving a change of host:</preamble>
   <artwork type="example">
Alt-Svc: h2="new.example.org:80"
</artwork>
<postamble>
   This indicates the "h2" protocol on the host "new.example.org", running
   on port 80. Note that the "quoted-string" syntax needs to be used because
   ":" is not an allowed character in "token".
</postamble>
</figure>
<texttable style="all" align="left">
  <preamble>Examples for protocol name escaping:</preamble>
  <ttcol>ALPN protocol name</ttcol>
  <ttcol>protocol-id</ttcol>
  <ttcol>Note</ttcol>

  <c>h2</c>
  <c>h2</c>
  <c>No escaping needed</c>

  <c>w=x:y#z</c>
  <c>w%3Dx%3Ay#z</c>
  <c>"=" and ":" escaped</c>

  <c>x%y</c>
  <c>x%25y</c>
  <c>"%" needs escaping</c>
</texttable>
<t>
   Alt-Svc &MAY; occur in any HTTP response message, regardless of the status code.
   Note that recipients of Alt-Svc can ignore the header field (and are required to 
   in some situations; see Sections <xref format="counter" target="host_auth"/> and <xref format="counter" target="status"/>).
</t>
<figure>
  <preamble>The Alt-Svc field value can have multiple values:</preamble>
  <artwork type="example">
Alt-Svc: h2="alt.example.com:8000", h2=":443"
</artwork>
</figure>
<t>
   When multiple values are present, the order of the values reflects the server's
   preference (with the first value being the most preferred alternative).
</t>
<t>
   The value(s) advertised by Alt-Svc can be used by clients to open a new
   connection to an alternative service. Subsequent requests can start using this new connection
   immediately or can continue using the existing connection while the new connection is created.
</t>
<t>
   When using HTTP/2 (<xref target="RFC7540"/>), servers &SHOULD; instead send an ALTSVC frame
   (<xref target="frame"/>). A single ALTSVC frame can be sent for a connection;
   a new frame is not needed for every request. Note that, despite this
   recommendation, Alt-Svc header fields remain valid in responses delivered over HTTP/2.
</t>
<t>
   Each "alt-value" is followed by an &OPTIONAL; semicolon-separated list of
   additional parameters, each such "parameter" comprising a name and a value.
</t>
<t>   
   This specification defines two parameters: "ma" and "persist", defined in
   <xref target="caching-alt-svc-header-field-values"/>. Unknown parameters
   &MUST; be ignored. That is, the values (alt-value) they appear in &MUST;
   be processed as if the unknown parameter was not present.
</t>
<t>
   New parameters can be defined in extension specifications (see
   <xref target="iana.parameters"/> for registration details).
</t>
<t>
   Note that all field elements that allow "quoted-string" syntax &MUST; be processed
   as per <xref target="RFC7230" x:fmt="of" x:rel="#field.components"/>.
</t>

<section title="Caching Alt-Svc Header Field Values" anchor="caching-alt-svc-header-field-values">
<t>
   When an alternative service is advertised using Alt-Svc, it is considered fresh
   for 24 hours from generation of the message. This can be modified with the "ma"
   (max-age) parameter.
</t>
<figure>
  <preamble>Syntax:</preamble>
  <artwork type="abnf2616">
ma = <x:ref>delta-seconds</x:ref>; see <xref target="RFC7234" x:fmt="," x:rel="#delta-seconds"/>
</artwork></figure>
<t>
   The delta-seconds value indicates the number of seconds since the response was generated for which the
   alternative service is considered fresh.
</t>
<figure>
  <artwork type="example">
Alt-Svc: h2=":443"; ma=3600
</artwork>
</figure>
<t>
   See <xref target="RFC7234" x:rel="#age.calculations" x:fmt="of"/> for details on determining
   the response age.
</t>
<figure>
  <preamble>For example, a response:</preamble>
  <artwork type="message/http; msgtype=&#34;response&#34;" x:indent-with="  ">
HTTP/1.1 200 OK
Content-Type: text/html
Cache-Control: max-age=600
Age: 30
Alt-Svc: h2=":8000"; ma=60
</artwork>
<postamble>
   indicates that an alternative service is available and usable for the next 60
   seconds. However, the response has already been cached for 30 seconds (as per
   the Age header field value); therefore, the alternative service is only fresh
   for the 30 seconds from when this response was received, minus estimated
   transit time.
</postamble>
</figure>
<t>
   Note that the freshness lifetime for HTTP caching (here, 600 seconds) does not
   affect caching of Alt-Svc values.
</t>
<t>
   When an Alt-Svc response header field is received from an origin, its value
   invalidates and replaces all cached alternative services for that origin.
</t>
<t>
   By default, cached alternative services will be cleared when the client detects a network
   change. Alternative services that are intended to be longer lived (such as those that are not
   specific to the client access network) can carry the "persist" parameter with a value "1" as a
   hint that the service is potentially useful beyond a network configuration change.
</t><figure>
  <preamble>Syntax:</preamble>
  <artwork type="abnf2616">
persist = "1"
</artwork></figure>
<t>
  For example:
</t>
<figure>
  <artwork type="example">
Alt-Svc: h2=":443"; ma=2592000; persist=1
</artwork>
</figure>
<t>
   This specification only defines a single value for "persist". Clients
   &MUST; ignore "persist" parameters with values other than "1".
</t>
<t>
   See <xref target="caching"/> for general requirements on caching alternative services.
</t>
</section>
</section>

<section anchor="frame" title="The ALTSVC HTTP/2 Frame">
<t>
  The ALTSVC HTTP/2 frame (<xref target="RFC7540" x:fmt="," x:rel="#FramingLayer"/>)
  advertises the availability of an alternative service to an HTTP/2 client.
</t>
<t>
  The ALTSVC frame is a non-critical extension to HTTP/2.  Endpoints that do
  not support this frame will ignore it (as per the extensibility rules defined in 
  <xref target="RFC7540" x:sec="4.1" x:fmt="of"/>).
</t>
<t>
  An ALTSVC frame from a server to a client on a stream other than stream 0
  indicates that the conveyed alternative service is associated with the origin
  of that stream.
</t>
<t>
  An ALTSVC frame from a server to a client on stream 0 indicates that the conveyed alternative
  service is associated with the origin contained in the Origin field of the frame. An association
  with an origin that the client does not consider authoritative for the current connection &MUST;
  be ignored.
</t>
<t>
  The ALTSVC frame type is 0xa (decimal 10).
</t>
<figure title="ALTSVC Frame Payload">
  <artwork type="drawing"><![CDATA[
 +-------------------------------+-------------------------------+
 |         Origin-Len (16)       | Origin? (*)                 ...
 +-------------------------------+-------------------------------+
 |                   Alt-Svc-Field-Value (*)                   ...
 +---------------------------------------------------------------+
]]></artwork>
</figure>
<t>
  The ALTSVC frame contains the following fields:
  <list style="hanging">
    <t hangText="Origin-Len:">
      An unsigned, 16-bit integer indicating the length, in octets, of the Origin field.
    </t>
    <t hangText="Origin:">
      An &OPTIONAL; sequence of characters containing the ASCII serialization of an
      origin (<xref target="RFC6454" x:fmt="," x:sec="6.2"/>) to which the alternative
      service is applicable.
    </t>
    <t hangText="Alt-Svc-Field-Value:">
      A sequence of octets (length determined by subtracting the length of all preceding fields
      from the frame length) containing a value identical to the Alt-Svc field value defined in
      <xref target="alt-svc"/> (ABNF production "Alt-Svc").
    </t>
  </list>
</t>
<t>
  The ALTSVC frame does not define any flags.
</t>
<t>
  The ALTSVC frame is intended for receipt by clients. A device acting
   as a server &MUST; ignore it.
</t>
<t>
  An ALTSVC frame on stream 0 with empty (length 0) "Origin" information is
  invalid and &MUST; be ignored. An ALTSVC frame on a stream other than stream
  0 containing non-empty "Origin" information is invalid and &MUST; be ignored.
</t>
<t>
  The ALTSVC frame is processed hop-by-hop.  An intermediary &MUST-NOT; forward ALTSVC frames,
  though it can use the information contained in ALTSVC frames in forming new ALTSVC frames
  to send to its own clients.
</t>
<t>
  Receiving an ALTSVC frame is semantically equivalent to receiving an Alt-Svc
  header field. As a result, the ALTSVC frame causes alternative services for
  the corresponding origin to be replaced. Note that it would be unwise to mix
  the use of Alt-Svc header fields with the use of ALTSVC frames, as the sequence
  of receipt might be hard to predict.
</t>
</section>

<section title="The Alt-Used HTTP Header Field" anchor="indicator">
<t>
   The Alt-Used header field is used in requests to identify the alternative
   service in use, just as the Host header field (<xref target="RFC7230" x:rel="#header.host"/>)
   identifies the host and port of the origin.
</t>
<figure>
<artwork type="abnf2616">
Alt-Used     = uri-host [ ":" port ]
</artwork>
</figure>
<t>
   Alt-Used is intended to allow alternative services to detect loops, differentiate
   traffic for purposes of load balancing, and generally to ensure that it is
   possible to identify the intended destination of traffic, since introducing
   this information after a protocol is in use has proven to be problematic.
</t>
<t>
   When using an alternative service, clients &SHOULD; include an Alt-Used
   header field in all requests.
</t>
<figure>
  <preamble>For example:</preamble>
  <artwork type="message/http; msgtype=&#34;request&#34;" x:indent-with="  ">
GET /thing HTTP/1.1
Host: origin.example.com
Alt-Used: alternate.example.net
</artwork>
</figure>
</section>

<section title="The 421 (Misdirected Request) HTTP Status Code" anchor="status">
<t>
   The 421 (Misdirected Request) status code is defined in <xref target="RFC7540"
   x:fmt="of" x:rel="#MisdirectedRequest"/> to indicate that the current server
   instance is not authoritative for the requested resource.  This can be used
   to indicate that an alternative service is not authoritative; see <xref
   target="alternative"/>).
</t>
<t>
   Clients receiving 421 (Misdirected Request) from an alternative service &MUST;
   remove the corresponding entry from its alternative service cache (see <xref
   target="caching"/>) for that origin. Regardless of the idempotency of the
   request method, they &MAY; retry the request, either at another alternative
   server, or at the origin.
</t>
<t>
   An Alt-Svc header field in a 421 (Misdirected Request) response &MUST; be ignored.
</t>
</section>

<section title="IANA Considerations" anchor="iana-considerations">

<section title="Header Field Registrations">
<t>
   HTTP header fields are registered within the "Message Headers" registry
   maintained at
   <eref target="https://www.iana.org/assignments/message-headers/"/>.
</t>
<t>
   This document defines the following HTTP header fields, so their associated
   registry entries have been added according to the permanent registrations below
   (see <xref target="BCP90"/>):
</t>
<texttable align="left" suppress-title="true" anchor="iana.header.registration.table">
   <ttcol>Header Field Name</ttcol>
   <ttcol>Protocol</ttcol>
   <ttcol>Status</ttcol>
   <ttcol>Reference</ttcol>

   <c>Alt-Svc</c>
   <c>http</c>
   <c>standard</c>
   <c>
      <xref target="alt-svc"/>
   </c>
   <c>Alt-Used</c>
   <c>http</c>
   <c>standard</c>
   <c>
      <xref target="indicator"/>
   </c>
</texttable>
<t>
  The change controller is: "IETF (iesg@ietf.org) -- Internet Engineering Task Force".
</t>
</section>

<section anchor="alt-svc-frame-registration" title="The ALTSVC HTTP/2 Frame Type">
<t>
  This document registers the ALTSVC frame type in the "HTTP/2 Frame Type"
  registry (<xref target="RFC7540" x:fmt="," x:rel="#iana-frames"/>).
  <list style="empty">
    <t>Frame Type: ALTSVC</t>
    <t>Code: 0xa</t>
    <t>Specification: <xref target="frame"/> of this document</t>
  </list>
</t>
</section>

<section anchor="iana.parameters" title="Alt-Svc Parameter Registry">
<t>
   The "Hypertext Transfer Protocol (HTTP) Alt-Svc Parameter Registry" defines the name space for
   parameters. It has been created and will be maintained at
   <eref target="http://www.iana.org/assignments/http-alt-svc-parameters"/>.
</t>

<section title="Procedure" anchor="parameter.registry.procedure">
<t>
   A registration &MUST; include the following fields:
   <list style="symbols">
      <t>Parameter Name</t>
      <t>Pointer to specification text</t>
   </list>
</t>
<t>
   Values to be added to this name space require Expert Review (see <xref
   target="RFC5226" x:fmt="," x:sec="4.1"/>).
</t>
</section>

<section title="Registrations" anchor="parameter.registrations">
<t>
  The "Hypertext Transfer Protocol (HTTP) Alt-Svc Parameter Registry" has been populated with the registrations below:
</t>
<texttable align="left" suppress-title="true">
   <ttcol>Alt-Svc Parameter</ttcol>
   <ttcol>Reference</ttcol>

   <c>ma</c>
   <c>
      <xref target="caching-alt-svc-header-field-values"/>
   </c>
   <c>persist</c>
   <c>
      <xref target="caching-alt-svc-header-field-values"/>
   </c>
</texttable>
</section>
</section>
</section>

<section title="Internationalization Considerations" anchor="internationalization-considerations">
<t>
   An internationalized domain name that appears in either the header field
   (<xref target="alt-svc"/>) or the HTTP/2 frame (<xref target="frame"/>)
   &MUST; be expressed using A-labels (<xref target="RFC5890" x:fmt="," x:sec="2.3.2.1"/>).
</t>
</section>

<section title="Security Considerations" anchor="security-considerations">

<section title="Changing Ports" anchor="changing-ports">
<t>
   Using an alternative service implies accessing an origin's resources on an
   alternative port, at a minimum. Therefore, an attacker that can inject alternative services
   and listen at the advertised port is able to hijack an origin.  On
   certain servers, it is normal for users to be able to control some personal
   pages available on a shared port and also to accept requests on less-privileged
   ports.
</t>
<t>
   For example, an attacker that can add HTTP response header fields to some pages
   can redirect traffic for an entire origin to a different port on the same host
   using the Alt-Svc header field; if that port is under the attacker's control,
   they can thus masquerade as the HTTP server.
</t>
<t>
   This risk is mitigated by the requirements in <xref target="host_auth"/>.
</t> 
<t>
   On servers, this risk can also be reduced by restricting the ability to advertise
   alternative services, and restricting who can open a port for listening on that host.
</t>
</section>

<section title="Changing Hosts" anchor="host_security">
<t>
   When the host is changed due to the use of an alternative service, this presents
   an opportunity for attackers to hijack communication to an origin.
</t>
<t>
   For example, if an attacker can convince a user agent to send all traffic for
   "innocent.example.org" to "evil.example.com" by successfully associating it as an alternative
   service, they can masquerade as that origin. This can be done locally (see mitigations in <xref
   target="changing-ports"/>) or remotely (e.g., by an intermediary as a man-in-the-middle attack).
</t>
<t>
   This is the reason for the requirement in <xref target="host_auth"/> that clients have
   reasonable assurances that the alternative service is under control of and valid for the whole
   origin; for example, presenting a certificate for the origin proves that the alternative service
   is authorized to serve traffic for the origin.
</t>
<t>
   Note that this assurance is only as strong as the method used to authenticate the alternative
   service. In particular, when TLS authentication is used to do so, there are well-known exploits
   to make an attacker's certificate appear as legitimate.
</t>
<t>
   Alternative services could be used to persist such an attack. For example, an
   intermediary could man-in-the-middle TLS-protected communication to a target
   and then direct all traffic to an alternative service with a large freshness
   lifetime so that the user agent still directs traffic to the attacker even when
   not using the intermediary.
</t>
<t>
   Implementations &MUST; perform any certificate-pinning validation (such as
   <xref target="RFC7469"/>) on alternative services just as they would on direct
   connections to the origin.  Implementations might also choose to add
   other requirements around which certificates are acceptable for alternative
   services.
</t>
</section>

<section title="Changing Protocols" anchor="changing-protocols">
<t>
   When the ALPN protocol is changed due to the use of an alternative service, the
   security properties of the new connection to the origin can be different from
   that of the "normal" connection to the origin, because the protocol identifier
   itself implies this.
</t>
<t>
   For example, if an "https://" URI has a protocol advertised that does not use
   some form of end-to-end encryption (most likely, TLS), this violates the
   expectations for security that the URI scheme implies.
   Therefore, clients cannot use alternative services blindly, but instead evaluate
   the option(s) presented to ensure that security requirements and expectations
   of specifications, implementations, and end users are met.
</t>
</section>

<section title="Tracking Clients Using Alternative Services" anchor="tracking">
<t>
   Choosing an alternative service implies connecting to a new, server-supplied
   host name. By using unique names, servers
   could conceivably track client requests. Such tracking could follow users
   across multiple networks, when the "persist" flag is used.
</t>
<t>
   Clients that wish to prevent requests from being correlated can decide not to use
   alternative services for multiple requests that would not otherwise be
   allowed to be correlated.
</t>
<t>
   In a user agent, any alternative service information &MUST; be removed when origin-specific data
   is cleared (typically, when cookies <xref target="RFC6265"/> are cleared).
</t>
</section>

<section title="Confusion regarding Request Scheme" anchor="confusion-regarding-request-scheme">
<t>
  Some server-side HTTP applications make assumptions about security based upon
  connection context; for example, equating being served upon port 443 with the
  use of an "https://" URI and the various security properties that implies.
</t>
<t>
  This affects not only the security properties of the connection itself, but
  also the state of the client at the other end of it; for example, a Web
  browser treats "https://" URIs differently than "http://" URIs in many ways, not just
  for purposes of protocol handling.
</t>
<t>
  Since one of the uses of Alternative Services is to allow a connection to be
  migrated to a different protocol and port, these applications can become
  confused about the security properties of a given connection, sending
  information (for example, cookies and content) that is intended for a secure context 
  (such as an "https://" URI) to a client that is not treating it as one.
</t>
<t>
  This risk can be mitigated in servers by using the URI scheme explicitly
  carried by the protocol (such as ":scheme" in HTTP/2 or the "absolute form" of
  the request target in HTTP/1.1) as an indication of security context, instead of
  other connection properties (<xref target="RFC7540" x:fmt="," x:rel="#HttpRequest"/>
  and <xref target="RFC7230" x:fmt="," x:rel="#absolute-form"/>).
</t>
<t>
  When the protocol does not explicitly carry the scheme (as is usually
  the case for HTTP/1.1 over TLS), servers can mitigate this risk by either
  assuming that all requests have an insecure context, or by refraining from
  advertising alternative services for insecure schemes (for example, HTTP).
</t>
</section>
</section>
  </middle>

  <back>

<references title="Normative References">

<reference anchor="RFC2119">
  <front>
    <title abbrev="RFC Key Words">Key words for use in RFCs to Indicate Requirement Levels</title>
    <author initials="S." surname="Bradner" fullname="Scott Bradner">
      <organization>Harvard University</organization>
    </author>
    <date year="1997" month="March"/>
  </front>
  <seriesInfo name="BCP" value="14"/>
  <seriesInfo name="RFC" value="2119"/>
</reference>

<reference anchor="RFC2818">
  <front>
    <title>HTTP Over TLS</title>
    <author initials="E." surname="Rescorla" fullname="E. Rescorla"/>
    <date year="2000" month="May"/>
  </front>
  <seriesInfo name="RFC" value="2818"/>
</reference>

<reference anchor="RFC3986">
  <front>
    <title abbrev="URI Generic Syntax">Uniform Resource Identifier (URI): Generic Syntax</title>
    <author initials="T." surname="Berners-Lee" fullname="Tim Berners-Lee">
      <organization abbrev="W3C/MIT">World Wide Web Consortium</organization>
    </author>
    <author initials="R." surname="Fielding" fullname="Roy T. Fielding">
      <organization abbrev="Day Software">Day Software</organization>
    </author>
    <author initials="L." surname="Masinter" fullname="Larry Masinter">
      <organization abbrev="Adobe Systems">Adobe Systems Incorporated</organization>
    </author>
    <date year="2005" month="January"/>
  </front>
  <seriesInfo name="STD" value="66"/>
  <seriesInfo name="RFC" value="3986"/>
</reference>

<reference anchor='RFC5226'>
  <front>
    <title>Guidelines for Writing an IANA Considerations Section in RFCs</title>
    <author initials='T.' surname='Narten' fullname='T. Narten'/>
    <author initials='H.' surname='Alvestrand' fullname='H. Alvestrand'/>
    <date year='2008' month='May' />
  </front>
  <seriesInfo name='BCP' value='26' />
  <seriesInfo name='RFC' value='5226' />
</reference>

<reference anchor="RFC5234">
  <front>
    <title>Augmented BNF for Syntax Specifications: ABNF</title>
    <author initials="D." surname="Crocker" fullname="D. Crocker" role="editor"/>
    <author initials="P." surname="Overell" fullname="P. Overell"/>
    <date year="2008" month="January"/>
  </front>
  <seriesInfo name="STD" value="68"/>
  <seriesInfo name="RFC" value="5234"/>
</reference>

<reference anchor="RFC5890">
  <front>
    <title>
      Internationalized Domain Names for Applications (IDNA): Definitions and
      Document Framework
    </title>
    <author initials="J." surname="Klensin" fullname="John Klensin"/>
    <date year="2010" month="August"/>
  </front>
  <seriesInfo name="RFC" value="5890"/>
</reference>

<reference anchor="RFC6066">
  <front>
    <title>Transport Layer Security (TLS) Extensions: Extension Definitions</title>
    <author initials="D." surname="Eastlake" fullname="D. Eastlake"/>
    <date year="2011" month="January"/>
  </front>
  <seriesInfo name="RFC" value="6066"/>
</reference>

<reference anchor="RFC6454">
  <front>
    <title>The Web Origin Concept</title>
    <author initials="A." surname="Barth" fullname="A. Barth"/>
    <date year="2011" month="December"/>
  </front>
  <seriesInfo name="RFC" value="6454"/>
</reference>

<reference anchor="RFC7230">
  <front>
    <title>Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing</title>
    <author fullname="Roy T. Fielding" initials="R." role="editor" surname="Fielding">
      <organization abbrev="Adobe">Adobe Systems Incorporated</organization>
      <address><email>fielding@gbiv.com</email></address>
    </author>
    <author fullname="Julian F. Reschke" initials="J. F." role="editor" surname="Reschke">
      <organization abbrev="greenbytes">greenbytes GmbH</organization>
      <address><email>julian.reschke@greenbytes.de</email></address>
    </author>
    <date month="June" year="2014" />
  </front>
  <seriesInfo name="RFC" value="7230" />
  <x:source href="rfc7230.xml"
            basename="https://svn.tools.ietf.org/svn/wg/httpbis/specs/rfc7230"/>
</reference>

<reference anchor="RFC7234">
  <front>
    <title>Hypertext Transfer Protocol (HTTP/1.1): Caching</title>
    <author initials="R." surname="Fielding" fullname="Roy T. Fielding" role="editor">
      <organization abbrev="Adobe">Adobe Systems Incorporated</organization>
      <address><email>fielding@gbiv.com</email></address>
    </author>
    <author fullname="Mark Nottingham" initials="M." role="editor" surname="Nottingham">
      <organization>Akamai</organization>
      <address><email>mnot@mnot.net</email></address>
    </author>
    <author initials="J. F." surname="Reschke" fullname="Julian F. Reschke" role="editor">
      <organization abbrev="greenbytes">greenbytes GmbH</organization>
      <address><email>julian.reschke@greenbytes.de</email></address>
    </author>
    <date month="June" year="2014" />
  </front>
  <seriesInfo name="RFC" value="7234"/>
  <x:source href="rfc7234.xml"
            basename="https://svn.tools.ietf.org/svn/wg/httpbis/specs/rfc7234"/>
</reference>

<reference anchor="RFC7301">
  <front>
    <title>Transport Layer Security (TLS) Application-Layer Protocol Negotiation Extension</title>
    <author initials="S." surname="Friedl" fullname="Stephan Friedl"/>
    <author initials="A." surname="Popov" fullname="Andrey Popov"/>
    <author initials="A." surname="Langley" fullname="Adam Langley"/>
    <author initials="S." surname="Emile" fullname="Stephan Emile"/>
    <date month="July" year="2014"/>
  </front>
  <seriesInfo name="RFC" value="7301"/>
</reference>

<reference anchor="RFC7405">
  <front>
    <title>Case-Sensitive String Support in ABNF</title>
    <author initials="P." surname="Kyzivat" fullname="Paul Kyzivat"/>
    <date year="2014" month="December"/>
  </front>
  <seriesInfo name="RFC" value="7405"/>
</reference>

<reference anchor="RFC7540">
  <front>
    <title>Hypertext Transfer Protocol version 2</title>
    <author initials="M." surname="Belshe" fullname="Mike Belshe"/>
    <author initials="R." surname="Peon" fullname="Roberto Peon"/>
    <author initials="M." surname="Thomson" fullname="Martin Thomson" role="editor"/>
    <date month="May" year="2015"/>
  </front>
  <seriesInfo name="RFC" value="7540"/>
  <x:source href="rfc7540.xml"
            basename="https://svn.tools.ietf.org/svn/wg/httpbis/specs/rfc7540"/>
</reference>

</references>

<references title="Informative References">

<reference anchor='BCP90'>
  <front>
    <title>Registration Procedures for Message Header Fields</title>
    <author initials='G.' surname='Klyne' fullname='G. Klyne'/>
    <author initials='M.' surname='Nottingham' fullname='M. Nottingham'/>
    <author initials='J.' surname='Mogul' fullname='J. Mogul'/>
    <date year='2004' month='September' />
  </front>
  <seriesInfo name='BCP' value='90' />
  <seriesInfo name='RFC' value='3864' />
</reference>

<reference anchor="RFC5246">
  <front>
    <title>The Transport Layer Security (TLS) Protocol Version 1.2</title>
    <author initials="T." surname="Dierks" fullname="T. Dierks"/>
    <author initials="E." surname="Rescorla" fullname="E. Rescorla"/>
    <date year="2008" month="August"/>
  </front>
  <seriesInfo name="RFC" value="5246"/>
</reference>


<reference anchor="RFC6265">
  <front>
    <title>HTTP State Management Mechanism</title>
    <author initials="A." surname="Barth" fullname="A. Barth"/>
    <date year="2011" month="April"/>
  </front>
  <seriesInfo name="RFC" value="6265"/>
</reference>

<reference anchor="RFC7469">
  <front>
    <title>Public Key Pinning Extension for HTTP</title>
    <author initials="C." surname="Evans" fullname="Chris Evans"/>
    <author initials="C." surname="Palmer" fullname="Chris Palmer"/>
    <author initials="R." surname="Sleevi" fullname="Ryan Sleevi"/>
    <date month="April" year="2015"/>
  </front>
  <seriesInfo name="RFC" value="7469"/>
</reference>

</references>


<section title="Acknowledgements" anchor="acknowledgements" numbered="false">
<t>
  Thanks to Adam Langley, Bence Beky, Chris Lonvick, Eliot Lear, Erik Nygren, Guy Podjarny,
  Herve Ruellan, Lucas Pardue, Martin Thomson, Matthew Kerwin, Mike Bishop,
  Paul Hoffman,
  Richard Barnes, Richard Bradbury, Stephen Farrell, Stephen Ludin,
  and Will Chan for their
  feedback and suggestions.
</t>
<t>
  The Alt-Svc header field was influenced by the design of the
  Alternate-Protocol header field in SPDY.
</t>
</section>
  </back>

</rfc>
