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