site

source files for beau's website
git clone https://git.beauhilton.com/site.git
Log | Files | Refs

index.html (4912B)


      1 <!DOCTYPE html>
      2 <html lang="en">
      3  <head>
      4   <link rel="stylesheet" href="/style.css" type="text/css">
      5   <meta charset="utf-8">
      6   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      7   <meta name="viewport" content="width=device-width, initial-scale=1.0">
      8   <link rel="stylesheet" type="text/css" href="/style.css">
      9   <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cstyle%3E %23m %7B opacity:0; %7D%0A@media (prefers-color-scheme: dark) %7B %23m %7B opacity:1; %7D %23e %7B opacity:0 %7D%0A%7D %3C/style%3E%3Ctext id='m' y='.9em' font-size='90'%3E🏕️%3C/text%3E%3Ctext id='e' y='.9em' font-size='90'%3E🌞%3C/text%3E%3C/svg%3E">
     10   <title></title>
     11  </head>
     12  <body>
     13   <div id="page-wrapper">
     14    <div id="header" role="banner">
     15     <header class="banner">
     16      <div id="banner-text">
     17       <span class="banner-title"><a href="/">beauhilton</a></span>
     18      </div>
     19     </header>
     20     <nav>
     21      <a href="/about">about</a>
     22 <a href="/now">now</a>
     23 <a class="nav-active" href="/posts">posts</a>
     24 <a href="https://notes.beauhilton.com">notes</a>
     25 <a href="https://talks.beauhilton.com">talks</a>
     26 <a href="https://git.beauhilton.com">git</a>
     27 <a href="/contact">contact</a>
     28 <a href="/feed.xml">rss</a>
     29     </nav>
     30    </div>
     31    <main>
     32     <h1>
     33      fix MIME Types to unbreak RSS feeds served by OpenBSD’s
     34 httpd(8)
     35     </h1>
     36     <p>
     37      <time id="post-date">2022-11-13</time>
     38     </p>
     39     <h2>
     40      RSS is life - but mine was broken
     41     </h2>
     42     <p>
     43      As of today (2022-11-13) my website lives on an OpenBSD server hosted
     44 at <a href="https://vultr.com">vultr</a>.
     45     </p>
     46     <p>
     47      It’s great, delightfully simple and low-resource, robust, extendable,
     48 low-maintenance.
     49     </p>
     50     <p id="post-excerpt">
     51      I've been getting back into RSS lately.
     52 Turns out, my own RSS feed was broken.
     53     </p>
     54     <p>
     55      I knew it was janky, but would have had no idea how broken it was if
     56 not for the great folks on the <a href="https://datasette.io">datasette</a> Discord, one of whom reached
     57 out to let me know my RSS link wasn’t working.
     58     </p>
     59     <p>
     60      This could not stand!
     61     </p>
     62     <p>
     63      I’ve been meaning to fix my RSS feed anyway, and now I had a good
     64 reason.
     65     </p>
     66     <h2>
     67      fixing the file itself
     68     </h2>
     69     <p>
     70      I ended up tearing out my previous RSS solution, <a href="https://romanzolotarev.com/rssg.html"><code>rssg</code></a>, which
     71 is great but made some assumptions about my site’s layout that aren’t
     72 true. I could have rewritten the script, but I’m lazy and a little
     73 strapped for time, so I ended up replacing it with a hand-written RSS
     74 file.
     75     </p>
     76     <p>
     77      (The RSS spec is easy enough to write by hand, a little copy-paste
     78 and replace to add a new article - at some point I’ll probably migrate
     79 to <code>hugo</code> or similar and hand off the feed creation to a more
     80 flexible script, but for now this works).
     81     </p>
     82     <p>
     83      After I was certain the file format was fine and had the info I
     84 wanted, I thought I was good.
     85     </p>
     86     <h2>
     87      fixing the MIME Type
     88     </h2>
     89     <p>
     90      The kind soul who reached out to let me know the RSS feed was
     91 malformed reached out again to let me know he was now getting a MIME
     92 Type error.
     93     </p>
     94     <p>
     95      My feedreader of choice, <code>newsboat</code>, is very forgiving of
     96 what it accepts, and didn’t throw any errors when I tested it.
     97 <code>FreshRSS</code>, on the other hand, is more strict, and the feed
     98 would fail even though the file itself was fine.
     99     </p>
    100     <p>
    101      I looked into it, and found out that <code>httpd(8)</code> only
    102 supports a handful of MIME Types by default, so my server was sending
    103 out <code>application/octet-stream</code> (a generic type) instead of
    104 the <code>rss+xml</code> type, and it was confusing the feedreader.
    105     </p>
    106     <h2>
    107      add all the types
    108     </h2>
    109     <p>
    110      Thank goodness, and as usual in OpenBSD, there’s a very easy way to
    111 add all the relevant types one might need.
    112     </p>
    113     <p>
    114      OpenBSD has an internal MIME declaration file you can link to from
    115 within <code>httpd.conf(5)</code>.
    116     </p>
    117     <p>
    118      Here’s the relevant bit, just chuck this on the end of the conf
    119 file:
    120     </p>
    121     <pre tabindex="0"><code class="language-shell">
    122 types {
    123     include "/usr/share/misc/mime.types"
    124 }
    125 </code></pre>
    126     <p>
    127      And reload <code>httpd(8)</code>.
    128     </p>
    129     <h2>
    130      great success
    131     </h2>
    132     <p>
    133      Much thanks to my new friend on the Datasette Discord, the fantastic
    134 OpenBSD documentation, as always, and <a href="https://blog.lambda.cx/posts/openbsd-httpd-mime-types/">lambda.cx</a>
    135 for writing a post almost identical to mine (except that his had nothing
    136 to do with RSS - he was fixing PDF serving, which should now be fixed on
    137 my site as well).
    138     </p>
    139    </main>
    140    <div id="footnotes"></div>
    141    <footer></footer>
    142   </div>
    143  </body>
    144 </html>