title: Plaintext HTTP in a Modern World
url: https://jcs.org/2021/01/06/plaintext
hash_url: 9e5d68c7459c77716c44dd1463be36d8

<p>On the modern web, everything must be encrypted.
Unencrypted websites are treated as relics of the past with browsers declaring
them toxic waste not to be touched (or
<a href="//blog.mozilla.org/security/2020/11/17/firefox-83-introduces-https-only-mode/">even looked at</a>)
and search engines de-prioritizing their content.</p>

<p>While this push for security is good for protecting modern communication, there
is a whole web full of information and services that don’t <em>need</em> to be secured
and those trying to access them from older vintage computers or even through
modern embedded devices are increasingly being left behind.</p>



<p class="alert">Note: This article is mostly directed at those serving personal websites, like
this one, with no expectation of privacy or security by most readers of the
content.
If you are running a commercial website, collecting personal information from
users, or transmitting sensitive data that users would expect to be done
privately, disregard everything here and don’t bother offering your website over
plaintext.</p>

<h2 id="http-upgrading">HTTP Upgrading</h2>

<p>Though it’s less common these days, users may still type in your website URL
manually as opposed to clicking on a link that already includes the <code class="language-plaintext highlighter-rouge">https</code>
scheme.
(Imagine a user hearing your website mentioned on a podcast and they have to
type it into their browser.)</p>

<p>For a URL entered with an <code class="language-plaintext highlighter-rouge">http</code> scheme or, more commonly, no scheme specified,
unless your domain is listed in the
<a href="//www.chromium.org/hsts"><abbr title="Strict Transport Security">STS</abbr> preload list</a>
of the user’s browser or they are using a plugin like
<a href="//www.eff.org/https-everywhere">HTTPS Everywhere</a>, the browser will
default to loading your website over plaintext HTTP.
For this reason, even if your website is only served over HTTPS, it’s still
necessary to configure your server to respond to plaintext HTTP requests with a
301 or 302 redirect to the HTTPS version of the URL.</p>

<p>If your server is properly configured to send a <code class="language-plaintext highlighter-rouge">Strict-Transport-Security</code>
header, once the user’s browser loads your website’s HTTPS version, the browser
will cache that information for days or months and future attempts to load your
site will default to the HTTPS scheme instead of HTTP even if the user manually
types in an <code class="language-plaintext highlighter-rouge">http://</code> URL.</p>

<h2 id="avoid-forced-upgrading-by-default">Avoid Forced Upgrading by Default</h2>

<p>This forced redirection is a major cause of websites becoming inaccessible on
vintage computers.
Your server responds to the HTTP request with a 301 or 302 status and no
content, and either a) the browser follows the redirection and tries to
negotiate an SSL connection, but your server doesn’t offer legacy SSL versions
or old ciphers so the negotiation fails, or b) the browser just doesn’t support
SSL/TLS at all and fails to follow the redirection.</p>

<p>A real-life example of this is that I recently purchased a Powerbook G4 and
updated it to MacOS X 10.5.8 from 2009.
It has a 1.5Ghz processor and 1.25Gb of RAM, and can connect to my modern WiFi
network and use most of my USB peripherals.
It includes a Mail client that can talk to my IMAP and SMTP servers, and a
Safari web browser which can render fairly modern CSS layouts.
However, it’s unable to view any content at all on Wikipedia simply because it
can’t negotiate TLS 1.2 with the ciphers Wikipedia requires.
Why is a decade-old computer too old to view encyclopedia articles?</p>

<p>A solution to this problem is for websites to continue offering their full
content over plaintext HTTP in addition to HTTPS.
If you’re using Nginx, instead of creating two <code class="language-plaintext highlighter-rouge">server</code> blocks with the <code class="language-plaintext highlighter-rouge">listen
*:80</code> version redirecting to the <code class="language-plaintext highlighter-rouge">listen *:443 ssl</code> version, use a single
<code class="language-plaintext highlighter-rouge">server</code> block with multiple <code class="language-plaintext highlighter-rouge">listen</code> lines, like so:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>server {
    server_name jcs.org;
    listen *:80;
    listen *:443 ssl http2;

    ssl_certificate ...;
    ssl_certificate_key ...;
    ...
    ssl_protocols TLSv1.2;
}
</code></pre></div></div>

<p>While it may seem counter to the point of this article, I recommend <strong>not</strong>
serving legacy SSL/TLS ciphers like SSLv3 to try to help older browsers.
These old protocols and ciphers are insecure and broken, and I feel it’s better
to make it clear to the user they’re connecting to a website in cleartext than
to offer a false sense of security by having the browser indicate a “secure
connection” when it’s being done over an old, broken protocol.
Also, while it may not be practical anymore, modern browsers might be
<a href="//en.wikipedia.org/wiki/Downgrade_attack">tricked into negotiating</a>
an old, broken cipher if your server still offers it.</p>

<p>Even if you do offer legacy protocols and ciphers to older browsers, your TLS
certificate might be signed by a certificate authority whose root certificate is
not trusted by older browsers.</p>

<h2 id="continue-upgrading-modern-browsers">Continue Upgrading Modern Browsers</h2>

<p>Now that your entire website is being offered to legacy browsers over HTTP,
modern browsers can still be directed to connect over HTTPS for added privacy by
responding to the
<a href="//developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Upgrade-Insecure-Requests"><code class="language-plaintext highlighter-rouge">Upgrade-Insecure-Requests</code></a>
header.
This header is only sent by modern browsers that support
<a href="//developer.mozilla.org/en-US/docs/Web/HTTP/CSP">CSP</a>
when making an HTTP request, so it’s a reasonable indicator that the client is
sufficiently modern and robust that it will be able to negotiate a TLS 1.2
connection if redirected to your site’s HTTPS version.</p>

<p>For Nginx, this can be done inside a <code class="language-plaintext highlighter-rouge">server</code> block by defining a variable
per-request that includes whether it was made over plaintext HTTP and whether it
included an <code class="language-plaintext highlighter-rouge">Upgrade-Insecure-Requests: 1</code> header:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>server {
    ...
    set $need_http_upgrade "$https$http_upgrade_insecure_requests";
    location / {
        if ($need_http_upgrade = "1") {
            add_header Vary Upgrade-Insecure-Requests;
            return 301 https://$host$request_uri;
        }

        ...
    }
}
</code></pre></div></div>

<p>This <code class="language-plaintext highlighter-rouge">location</code> block will respond for any request and, for those made over
plaintext HTTP where <code class="language-plaintext highlighter-rouge">$https</code> will be blank and which included an
<code class="language-plaintext highlighter-rouge">Upgrade-Insecure-Requests: 1</code> header, they will be offered a 301 redirection to
the HTTPS version.
The <code class="language-plaintext highlighter-rouge">Vary</code> header is sent so that any caching proxies in the middle won’t cache
the redirect.</p>

<h2 id="content-concessions">Content Concessions</h2>

<p>With legacy browsers now able to access your site, you may want to make some
changes to your HTML and CSS to allow your site to render with some degree of
readability.
I don’t recommend giving it the full IE6 treatment catering to the lowest common
denominator, but at least make the main text of your site readable.</p>

<p>Obviously avoid JavaScript unless it is used progressively, though many older
browsers raise error dialogs at the mere presence of modern JavaScript that
can’t be parsed even if it’s never executed.</p>

<p>Modern CSS and complex layouts can also be a problem even for browsers just a
few years old, so it’s probably best to use them sparingly.
For any <code class="language-plaintext highlighter-rouge">&lt;a&gt;</code> or <code class="language-plaintext highlighter-rouge">&lt;img&gt;</code> tags that are local to your site, use relative links to
avoid specifying a particular scheme.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;a href="/posts/blah"&gt;
&lt;img src="/images/..."&gt;
&lt;/a&gt;
</code></pre></div></div>

<p>If you have to specify an absolute URL to another site that is also available
over both HTTP and HTTPS, you can specify it without a scheme or colon and the
browser will use the same <code class="language-plaintext highlighter-rouge">http:</code> or <code class="language-plaintext highlighter-rouge">https:</code> that the document is being viewed
over:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;a href="//other.example.com/"&gt;My other site&lt;/a&gt;
</code></pre></div></div>

<h2 id="a-rant-about-gemini">A Rant About Gemini</h2>

<p>Tangentially related,
<a href="//gemini.circumlunar.space/">Gemini</a>
is a modern document transfer protocol that aims to fit between the ancient
<a href="//en.wikipedia.org/wiki/Gopher_(protocol)">Gopher</a>
protocol and the too-modern HTTP web.
Its document markup language is based on
<a href="//en.wikipedia.org/wiki/Markdown">Markdown</a>
so it’s very lightweight and simple to parse without complex HTML/CSS parsers.</p>

<p>It sounds like the perfect thing to bring modern content to vintage computers,
except that its
<a href="//gemini.circumlunar.space/docs/specification.html">protocol</a>
requires all content to be transferred over TLS 1.2 or higher which makes it
nearly impossible to access from a vintage computer or even a modern embedded
system with limited CPU power.</p>

<p>This requirement seems poorly thought out, especially considering the Gemini
protocol doesn’t even support forms (other than a single text box on a search
form) so there’s no chance of users submitting private data, and there’s no
mechanism for client-server sessions so clients can’t be authenticated, meaning
everything served pretty much has to be public anyway.</p>

<p>Its protocol author argues that TLS is just a simple dependency no different
than a TCP server module, so it should be trivial to implement in any client or
server.
But if your computer’s CPU is so slow that a modern TLS negotiation would take
so long as to be unusable, or its
<a href="http://tenfourfox.blogspot.com/2018/02/the-tls-apocalypse-reaches-power-macs.html">platform doesn’t have a TLS 1.2 library</a>
available, that makes it difficult to write a client without depending on an
<a href="//github.com/jcs/sockhole">external system</a>
[<a href="https://oldvcr.blogspot.com/2020/11/fun-with-crypto-ancienne-tls-for.html">2</a>].</p>

<p>In my opinion, the protocol should <em>recommend</em> that servers offer both plaintext
and TLS encrypted versions and <em>recommend</em> that clients prefer TLS, but <em>may</em>
use plaintext if needed.
Clients for modern operating systems can continue enforcing a TLS requirement so
their users aren’t feeling any less secure.</p>

<p>Perhaps just sending actual Markdown text over plaintext HTTP to clients that
ask for it can be the new, old web.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Accept: text/markdown,text/plain;q=0.9,*/*;q=0.1
</code></pre></div></div>

<hr />

<p><em>Please don’t contact me to “well ackchyually” me and explain
<a href="/2011/08/17/a_man-in-the-middle_attack_in_the_wild">MITM attacks</a>
and how your terrible ISP inserts ads into your unencrypted web pages and how
you were able to make a Gemini client out of a whistle and some shoelaces.
If you don’t want to make your website content available to stupid old
computers, then don’t.</em></p>
