Tag Archive for: IIS

A Quick Look at IIS Crypto

22 Apr 2014
April 22, 2014

For many years now – I think about a decade — I have been building and managing Windows Web servers for a SaaS company. First as a contractor, then an employee and most recently as a consultant (tip: relationships matter). While I don’t have it down to an automated science, I do have pretty detailed checklists that I run through as part of each build.

My goal has always been to keep the server configurations consistent yet adapt as each new Windows Server release comes out. My first checklist was for a Server 2000 build. The one I updated last week was for 2012 R2. That’s covering some serious territory.IIS has certainly changed a lot over the years.

Of course, a big part of the builds revolves around security. One aspect of security is managing the SSL protocols and cipher suites offered by IIS. And, more importantly, which ones you do not wish to offer. I’ve documented this over the years and done some automation with batch files, vbs files (I know, I know…) and even .reg (registry import) files.

As I was updating the most recent servers last week I thought I had better do some quick research and make sure my notes were still current. These things date back 5 – 10 years after all. For instance, I know just half a year ago we went through the servers and disabled RC4 at Microsoft’s suggestion. That was never folded into my build notes…

While looking for SSL security updates I stumbled over a very handy little utility: IIS Crypto. I downloaded the tool, tried it on a dev server and then hit it with an external Qualys scan. It worked great – and fixed up a few holes that I had incorrectly plugged over the years (whoops). Now IIS Crypto is part of my toolbox.

IIS Crypto Screenshot

Just download and run it on your web server and choose the “Template” that applies. For me, that’s Best Practices with one click, then a second click to disable RC4 128/128 just to be consistent. Hit apply, schedule a reboot and you’re in good shape. Need to be PCI or FIPS compliant? Those are templates there as well.

There’s even a quick way to scan yourself from Qualys SSL labs.

Very slick. Highly recommended.

From their site:

IIS Crypto is a free tool that gives administrators the ability to enable or disable protocols, ciphers, hashes and key exchange algorithms on Windows Server 2003, 2008 and 2012. It also lets you reorder SSL/TLS cipher suites offered by IIS, implement best practices with a single click and test your website.

IIS: No Monitoring Hits in the Logs

12 Sep 2010
September 12, 2010

A few weeks ago I wrote about how I was changing my IIS web server configurations to (hopefully) better manage memory and App Pools. That’s been working out quite satisfactorily. Yesterday I realized the changes I made can give another nice side effect.

I was preparing to start some maintenance yesterday morning and I wanted to make sure nobody was hitting the development web server. One easy way to do that is to just check the IIS logs and that’s what I did. Open the log, jump to the end and then scroll back up past all the once a minute “is the server up?” monitoring hits … and it suddenly hit me, those monitoring hits don’t need to be there!

It would be nice to be able to open a log file, jump to the bottom and see the last real hit without having to filter through all the monitoring hits. Since I recently put the page the monitors hit in his own Application (and app pool) this is remarkably trivial to do. One mouse click, in fact.

Seems obvious, doesn’t it? Just uncheck “Log visits.” I couldn’t do this in the past since the monitoring page was in the same app / app pool as all the client sites. But now I can — and I like it.

Oh, Did You Want a Timeout?

24 Aug 2010
August 24, 2010

Back in February I mentioned that I was reconfiguring my IIS 6 web servers to shutdown the App Pools after 2 hours of inactivity. That seemed a much better option than the brute force iisreset that I’d been scheduling as a nightly event.

Turns out I wasn’t quite done yet. Here’s a snip of a conversation I had earlier today with my CTO, Hans.

“Ya know, I wish I had some better tools to see how many active users we have across all the sites at a given moment,” I said. “That would be helpful when I want to sneak in a quick change during the day.”

“Well what do you currently do to check?” he asked.

“I just pop open the latest IIS log file, jump to the bottom and see if the most recent entries are from my once-a-minute WhatsUp Gold site monitoring. If the last few entries are from WhatsUp then I know we’ve been idle that many minutes.”

He nodded and we moved onto another issue which resolved around some memory related issues.

I commented, “It seems like this main w3p process never shrinks. It just keeps growing its memory usage. How weird. Come to think of it, I’ve never seen a Windows Event about it shutting down or spinning back up…”

Hans just gave me the look and said, “Didn’t you mention your monitoring process hits that site every minute?”


“oh yeah… I guess it’ll never hit that 2 hour timeout, huh?” Don’t laugh… If you poll the site every minute don’t expect it to ever go idle!

Today I spent some time fixing that. I’m not sure what the best practices are but I have an approach that seems reasonable.

First, I created a new site with just one page (ping.html). Next, I created a new App Pool called monitoring just like the Default. But instead of a timeout I configured it to restart itself at 1:00 AM nightly. Then I converted that new site to an IIS application using that new App Pool.

IIS App Pool settings

My maint site's IIS app settings

I changed the WhatsUp monitor to use a custom HTTP Content monitor pointed at the new site. Now it tests for content from the ping.html page instead of just seeing if something responds on port 80 so this is probably even a bit better than it was before.

This brought up another small issue though.

Wait! How do I know which w3p process ties to which App Pool?

Now I have more App Pools all running as the same user. How can I quickly tell which process goes to which pool? Easy!

This picture lays it out:

App Pools and w3p processes

On the IIS server bring up a command prompt, navigate to the system32 directory and run:

cscript iisapp.vbs

The output lists the process ID (PID) and name for each w3p.exe process. Problem solved.

A Quick Look at Log Parser

18 Mar 2010
March 18, 2010

This morning I was alerted to the fact that one of our clients was having problems with our application last night. Unfortunately, none of their end users had captured any of the error messages. I checked the SQL and Windows Event logs but found nothing helpful. Then I had a look in into the IIS web service logs and found some clues.

Working with IIS logs is a bummer. They’re big, unwieldy text files and just a pain to work with. I asked on Twitter for suggestions. Jjakubowski replied with a link to Log Parser so I went to have a look. As soon as I saw the page I recalled that I’ve actually used this free Microsoft utility in the past (man, my memory…). I recall that I wasn’t entirely comfortable with it at the time but decided to dig a little deeper.

Long story short: This thing rocks. It can parse and process just about anything:

Log parser is a powerful, versatile tool that provides universal query access to text-based data such as log files, XML files and CSV files, as well as key data sources on the Windows® operating system such as the Event Log, the Registry, the file system, and Active Directory®. You tell Log Parser what information you need and how you want it processed. The results of your query can be custom-formatted in text based output, or they can be persisted to more specialty targets like SQL, SYSLOG, or a chart.

I rolled up my sleeves, wrote some SQL and after a bit of experimentation had some great queries built that really helped show where the issues were.

I’m not going attempt to build a tutorial on how to use this beast, but I’ll share a few links and tips that some might find useful.

Tip 1: There’s a help file (.chm) included in the download. Don’t ignore it – it is full of useful information and examples. Seriously. Check the help file before hitting your web search engine of choice. Among other things you can quickly find the column headings (and descriptions) for the type of file you’re working on.

Tip 2: You don’t have to formally install Log Parser.exe on all your machines. Once you have it one you can copy the .exe around. For instance, I copied it up to one of my network shares so that I can easily run it from any of the web servers without having to install anything (I keep some useful .sql files in that same share).

Tip 3: IIS dates are in UTC which can make ‘em a bit of a pain when looking for time-based events. My brain gets tired after having to mentally translate all the times I’m reviewing…

Check out this date handling in this query designed to show errors from the ASP pages:

SELECT  LogFilename, LogRow
, TO_DATE(TO_LOCALTIME(TO_TIMESTAMP(date, time))) as date
, TO_TIME(TO_LOCALTIME(TO_TIMESTAMP(date, time))) as time
, cs-method, cs-uri-stem, cs-uri-query, cs(User-Agent)
FROM <1>
WHERE (sc-status = 500) AND (cs-uri-stem LIKE '%.asp')

Cool, huh? (Cheerfully lifted those functions from this handy little presentation)

And speaking of dates: Suppose you’re looking for recent events in your IIS logs. While you could use some date logic in your query’s WHERE clause, Log Parser will still have to chug through all your log files. That could be a lot of unnecessary processing. Speed things up by using minDateMod parameter to specify the minimum file last modified date (local time) to look at.

So let’s tie that all together. Save that example query up there to a file called ASPerrors.sql. Now run something like this to query everything, but only after midnight on March, 8 2010:

LogParser file:ASPerrors.sql –i:IISw3c -minDateMod:"2010-03-08 00:00:00" –o:datagrid

Tip 4: Check out the datagrid. See that last –o parameter on the example above? That sends the output of your query to a nifty little grid window. This is invaluable while tweaking your query or just doing research. Faster and easier than sorting things out at the command prompt or capture output in text files. Once you have the query nailed down you can change the –o parm to a more appropriate format if desired.

Bonus tip: Click “All rows” when the datagrid shows up after running your query.

Tip 5: Take some time and look at examples on the web. There are tons and you’ll get some great ideas!

Log Parser initially looks a little humble and archaic due the command line nature, but dig into it a bit and you’ll be amazed by the power and potential.

Oh, I should mention that I looked into some GUI apps to help ease using Log Parser but didn’t really hit jackpot. First I tried Visual Logparser but couldn’t get it to even start on my Win7x64 machine. Next I tried Log Parser Lizard. This one shows some real potential, but every now and then it would go to 100% CPU while running a query and never come back. I can’t deny that my query may have been flawed, but I’d rather just get an error :-)