Sometimes we get requests at work that seem easy. Today, a customer wanted to make his log files available via his browser. I did the normal things; disabled anonymous access to the logs virtual directory, enabled directory browsing, etc. However, when I tried to view the log files, IIS kept kicking back a 404 error eventhough I was clicking on the file. “How can I get a 404 error when I am clicking on the fucking file?” I’m a Linuxhead, and I spent too much time on a stupid Windows issue. So, I decided to ask our company “Helpdesk” (which is manned by system administrators). After a brief description of the problem and some specific domain names and URLs (which I edited out for my blog), the following is the conversation I had with our Helpdesk.
<wafwot> You can click on the folder/dir named W4PGC355727236 but when you click on the files in the folder, the server kicks back a 404 error.
<Helpdesk> when i click on the W4PGC355727236 folder, I don't see a 404
<Helpdesk> i see a listing of the files in that dir
<wafwot> Okay... Can you click on the files?
<Helpdesk> ah. the files themselves, no.
I moved onto another issue. About a half hour passed before I got more response.
<Helpdesk> it has something to do with the file extension.
<Helpdesk> renaming the files to anything other than .log makes it so that doesn't happen.
<Helpdesk> compare http://www.example.com/logs/ex050727.txt with http://www.example.com/logs/ex050727.log
<wafwot> Odd.
<Helpdesk> something special is happening for .log files and I can't tell what it is
<Helpdesk> do people normally access their log files via HTTP?
<wafwot> Not normally... but this bonehead requested it.
<wafwot> Guess the answer is NO.
<Helpdesk> yeah. this is turning into a, "sorry, use ftp." i can't see anything in the configuration that treats .log files differently.
<wafwot> We all have better things to do than mess with Windows...
<wafwot> ...even if that's picking our noses with a claw hammer.
Some googling and another thirty minutes later, I found a forum where someone else had the same issue. In that thread, the concensus was to add a MIME type. My first thought was “bullshit.” I added a stinking MIME type, and the problem was solved!
<wafwot> Can you believe it was as easy as adding a MIME type? In IIS, get properties for the domain, click HTTP Headers tab, click the MIME Types button at the bottom of the dialog box, click New, enter "log" for extension and "text/plain" for Content Type. That's it!
<Helpdesk> wtf
<Helpdesk> lack of a mime type should NEVER EVER EVER yield a 404.
<Helpdesk> faggots.
<wafwot> Yeah... I dunno. GDMS.
<Helpdesk> seriously.
<wafwot> I could make the content type "x-application/attachment" and when the file is clicked on, it would open a download dialog.
<Helpdesk> x-asshat/microsoft
<wafwot> lol
<Helpdesk> i'm so pissed a lack of MIME TYPE caused this error.
<Helpdesk> wtf were they thinking?
<wafwot> I don't think they were.