So you've decided to take the plunge and make a site using XML and XSLT. 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 change1. For the purposes of these notes I'm going to assume that you can get Nginx installed and activated.
Once that's done, you'll want to edit your nginx.conf
2.
Enabling gzip
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:
gzip on;
gzip_disable "mise6";
gzip_types text/plain text/css text/xml application/xml text/xsl application/xml+rss;
This tells Nginx to turn on gzip support, unless someone is browsing your site with Internet Explorer 6 for some reason3. We also have to specify the kinds of files we want to gzip. You might notice that XML 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.
MIME Types
By default, Nginx doesn't know what an XSLT file is. You can tell it by editing the mime.types
and adding a line to the 'types' stanza
text/xsl xsl
Host config
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.
You'll need to locate the line in either the main nginx.conf
file or the appropriate virtual host config file that details what files nginx uses to serve up index pages4
You're looking for the line that says index
and you want to add index.xml
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.
Testing it out
To test that this is working, go to the root of the directory where your website files live, create a file called index.xml
, put valid XML into it, then enter the URL of your website into your favorite web browser and see what you get.
If your XML 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.
Congratulations! You've now cofigured Nginx to serve XML and XSLT. I'm sorry to have corrupted you.