site

files for beauhilton.com
git clone https://git.beauhilton.com/site.git
Log | Files | Refs

mime.md (2843B)


      1 # fix MIME Types to unbreak RSS feeds served by OpenBSD's httpd(8)
      2 
      3 
      4 <time id="post-date">2022-11-13</time>
      5 
      6 
      7 ## RSS is life - but mine was broken
      8 
      9 
     10 As of today (2022-11-13) my website lives on 
     11 an OpenBSD server hosted at [vultr](https://vultr.com).
     12 
     13 It's great, delightfully simple and low-resource,
     14 robust, extendable, low-maintenance.
     15 
     16 <p id="post-excerpt">
     17 I've been getting back into RSS lately.
     18 Turns out, my own RSS feed was broken.
     19 </p>
     20 
     21 I knew it was janky, but would have had no idea how broken it was
     22 if not for the great folks
     23 on the [datasette](https://datasette.io) Discord,
     24 one of whom reached out to let me know my RSS link wasn't working.
     25 
     26 This could not stand!
     27 
     28 I've been meaning to fix my RSS feed anyway,
     29 and now I had a good reason.
     30 
     31 
     32 ## fixing the file itself
     33 
     34 
     35 I ended up tearing out my previous RSS solution, [`rssg`](https://romanzolotarev.com/rssg.html),
     36 which is great but made some assumptions about my site's layout that aren't true.
     37 I could have rewritten the script, 
     38 but I'm lazy and a little strapped for time,
     39 so I ended up replacing it with a hand-written RSS file.
     40 
     41 (The RSS spec is easy enough to write by hand,
     42 a little copy-paste and replace to add a new article - 
     43 at some point I'll probably migrate to `hugo` or similar
     44 and hand off the feed creation to a more flexible script,
     45 but for now this works).
     46 
     47 After I was certain the file format was fine and had the info I wanted,
     48 I thought I was good.
     49 
     50 
     51 ## fixing the MIME Type
     52 
     53 
     54 The kind soul who reached out to let me know the RSS feed was malformed 
     55 reached out again to let me know he was now getting a MIME Type error.
     56 
     57 My feedreader of choice, `newsboat`, 
     58 is very forgiving of what it accepts, 
     59 and didn't throw any errors when I tested it.
     60 `FreshRSS`, on the other hand, is more strict, 
     61 and the feed would fail even though the file itself was fine.
     62 
     63 I looked into it, and found out that `httpd(8)`
     64 only supports a handful of MIME Types by default,
     65 so my server was sending out `application/octet-stream`
     66 (a generic type) instead of the `rss+xml` type,
     67 and it was confusing the feedreader.
     68 
     69 
     70 ## add all the types
     71 
     72 
     73 Thank goodness, and as usual in OpenBSD, 
     74 there's a very easy way to add all the relevant types one might need.
     75 
     76 OpenBSD has an internal MIME declaration file you can link to from within `httpd.conf(5)`.
     77 
     78 Here's the relevant bit, just chuck this on the end of the conf file:
     79 
     80 ```shell
     81 
     82 types {
     83     include "/usr/share/misc/mime.types"
     84 }
     85 
     86 ```
     87 
     88 And reload `httpd(8)`.
     89 
     90 
     91 ## great success
     92 
     93 
     94 Much thanks to my new friend on the Datasette Discord, 
     95 the fantastic OpenBSD documentation,
     96 as always,
     97 and [lambda.cx](https://blog.lambda.cx/posts/openbsd-httpd-mime-types/)
     98 for writing a post almost identical to mine 
     99 (except that his had nothing to do with RSS - 
    100 he was fixing PDF serving, 
    101 which should now be fixed on my site as well).
    102