<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../articles/article.xsl"?> 

<articles>
  <article date="28 Sep 2020">
    <pagetitle>The Amazing Nginx!</pagetitle>
    <articleheader>Setting up Nginx to serve <span class="danger">XML</span> and <span class="danger">XSLT</span></articleheader>
    <articleabstract>A few notes on some configuration you might want to do if you decided to enable <span class="danger">XML</span> and <span class="danger">XSLT</span> on your site for some reason.</articleabstract>
    <articlebody>

<p>So you've decided to take the plunge and make a site using <span class="danger">XML</span> and <span class="danger">XSLT</span>. First of all, my condolences. Second of all, assuming you've decided to use Nginx, there are a few configuration settings that you need to change<sup class="inlinefootnote">1</sup>. For the purposes of these notes I'm going to assume that you can get Nginx installed and activated.</p>

<p>Once that's done, you'll want to edit your <code>nginx.conf</code><sup class="inlinefootnote">2</sup>.</p>

<h3>Enabling gzip</h3>

<p>The first thing to do is to enable gzip. It's a good idea to do this to minimize web traffic. You can do this by going to the HTTP stanza and adding the following lines:</p>

<pre><code>gzip  on;

    gzip_disable "mise6";

    gzip_types text/plain text/css text/xml application/xml text/xsl application/xml+rss;</code></pre>

<p>This tells Nginx to turn on gzip support, unless someone is browsing your site with Internet Explorer 6 for some reason<sup class="inlinefootnote">3</sup>. We also have to specify the kinds of files we want to gzip. You might notice that <span class="danger">XML</span> is listed twice. That's because it's apparently given a MIME type of plain text and sometimes as an application. I just put both in there to cover my bases.</p>

<h3>MIME Types</h3>

<p>By default, Nginx doesn't know what an <span class="danger">XSLT</span> file is. You can tell it by editing the <code>mime.types</code> and adding a line to the 'types' stanza</p>

<pre><code>text/xsl	xsl</code></pre>

<h3>Host config</h3>

<p>This part is going to be a little bit different depending on if you use Virtual Hosts or not. If you don't know what Virtual Hosts are, then you're probably not using them.</p>

<p>You'll need to locate the line in either the main <code>nginx.conf</code> file or the appropriate virtual host config file that details what files nginx uses to serve up index pages<sup class="inlinefootnote">4</sup></p>

<p>You're looking for the line that says <code>index</code> and you want to add <code>index.xml</code> to the list. You can remove the other entries if you want to, but it's probably going to be handy later on if you don't do that.</p>

<h3>Testing it out</h3>

<p>To test that this is working, go to the root of the directory where your website files live, create a file called <code>index.xml</code>, put valid <span class="danger">XML</span> into it, then enter the URL of your website into your favorite web browser and see what you get.</p>

<p>If your <span class="danger">XML</span> is copied from the footnote below, then you will probably see a message complaining that the document doesn't have any style information (because it doesn't), and you'll just see a tag and the value in between the tags.</p>

<p>Congratulations! You've now cofigured Nginx to serve <span class="danger">XML</span> and <span class="danger">XSLT</span>. I'm sorry to have corrupted you.</p>

</articlebody>
    <footnotes>
      <footnote>This is definitely not me just writing down what I did so I can recreate it the next time I need to set up a server or something. Nope. Definitely not.</footnote>
      <footnote>Its location will depend on what operating system you're using. Linux distributions usually put it in <code>/etc/nginx</code> and FreeBSD puts it in <code>/usr/local/etc/nginx</code></footnote>
      <footnote>IE6 supports <span class="danger">XML</span> and <span class="danger">XSLT</span>, so on the off chance that someone has taken the time to get a version of Windows old enough to still run IE6 on the Internet and then browse to your site for some reason, we don't want them to be left out, I guess.</footnote>
      <footnote>And if you don't know what index pages are, you probably should do some research on the basics of website creation, and then come back to this article later.</footnote>
      <footnote>If you don't want to bother creating a whole slew of <span class="danger">XML</span> just for one page, the following snippet should be valid: <code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;tag&gt;Hello&lt;/tag&gt;</code></footnote>
    </footnotes>
  </article>
</articles>
