Category Archives: Windows Server

Serve static content from a cookieless domain – Google Page Speed Tip

Ok, so you are using the Google Page Speed plugin for Firefox and you can’t figure out how to clear the “Serve the following static resources from a domain that doesn’t set cookies” issue so that you score better…

First off, since we are using the Windows platform for our hosting, this entire post is making a big assumption you are too. If you are using some other platform or don’t have complete console or remote desktop access to your server, you can read on, but you’ll need to figure out this on your own.

The main thing you need to do is to REGISTER A NEW DOMAIN – or use one you’ve never used before – to specifically use for image and non-html things like JS and CSS.

If the web site is at this-is-my-site.com you should register this-is-my-site-static.com or something similar. YOU MUST register or use a completely different domain name than the base site.

Why is this? Because the way browsers store and cache cookies locally, even if you create a subdomain of your existing site, like static.this-is-my-site.com, the Google Page Speed score will still detect that that domain accepts cookies, and this will not suffice. Pick a domain that you’ve never used or hosted before and this will work fine. Keep in mind your web site visitors are NEVER going to know your images on are a different domain unless they start poking around in your HTML source code anyways.

This specific information will reference IIS 7.0, so if you are on an earlier version feel free to comment and I will see if I can pass along the settings.

So now that you’ve got your new and unused domain name ready to do, setup a new web site instance on your web server, preferably the latest OS such as Windows 2008 server.

DO NOT START the site after you set it up. Bind the site IP to the new domain name.

Bind it to the NO-MANAGED-CODE Application pool.

On this specific site you created, double click HANDLER MAPPINGS. Remove ASP, ASP.NET, PHP or any other script based handlers that appear here. ISAPI ones are OK to keep.

Start the web site instance.

You’ll now need to copy over your images to the new domain (via FTP or however).

Copy the following types of files

  • All images – png, gif, jpg
  • CSS files
  • favicon.ico file
  • JS files

In your HTML on your base site you’ll need to update ALL the image, CSS, JS, Favicon, and JS references to point to the server. You should know how to do this if you can get this far. We are talking HTML 101 here… 🙂

If you’ve done this all properly, re-run the Google Page Speed plugin and it should remove these issues off your task list and change them to “green checks”. If it doesn’t you probably have some script engine enabled on the domain and it is setting a cookie automatically (like ASP.NET). Remove it off that site.

Here at Amixa we use a dedicated server with all the script engines (ASP, ASP.NET, etc.) completely disabled to “serve cookieless domain content”.

TS Gateway – the poor man’s GotoMyPC

Want to connect into your business network, but don’t want to spend the $$$ paying for multiple GoToMyPC accounts?  Well, if you have control over your firewall, a static IP, Windows Server 2008 or later on your business server, and enough technical expertise, you can likely use Terminal Services Gateway service (TS Gateway) to connect into your computer (or any modern Windows OS computer on your LAN), for free!

  1. Start by reading the official Microsoft TS Gateway step-by-step guide.  Be aware even for me, a tech geek, that contains a pretty heavy duty dose of tech-babble.
  2. Configure your Windows 2008 server by reading these directions
  3. Configure each remote client (like your laptop) by reading this

Rather than re-hash all the above content, I will point out a few areas in which you may experience problems configuring  TS Gateway.

  • Configure a DNS record for your domain and point it at the office IP address, such as tsgateway.yourdomain.com point to your office IP.  If you don’t know your office IP, look at your firewall.  You will need a static IP or the capability to use a Dynamic IP address tracking service. If you don’t know what I am talking about already, this is not for you- use GoToMyPC!
  • While setting up the server, just create a “self signed” SSL certificate, and make sure you use the domain name you configured above to generate the self signed SSL, such as tsgateway.yourdomain.com
    • You will need to install this self-signed SSL into BOTH the server and client Trusted Root Certification Authorities store (the above links detail this process).
  • After the TS Gateway setup is complete, go check the IIS server BINDINGS for your default site and make sure the SSL certificate from above is properly installed onto your site.
  • These self-signed SSL certs expire after 6 months, so every 6 months you’ll need to generate a new one using the TS Gateway manager, or you can obtain a low cost SSL from GoDaddy or somewhere else that you can use as well. My advice is to just use the free self-signed ones.  If you are using self-signed ones just setup an Outlook recurring calendar event to remind you a week before each 6 month period.
  • Firewall configuration.  This is the most important part of the whole setup.  If the traffic can’t even get into your network, none of the above will work.
    • In general this is a two part process.
      • First, configure your NAT mappings, to map inbound port 443 TCP to your internal server IP address.
      • Second, add a rule to permit HTTPS traffic from anywhere to your internal server IP and HTTPS port 443
    • If you have properly configured your firewall, and imported in both the client and server SSL cert, go to an outside connection with your laptop (like a coffee shop) and go to https://tsgateway.yourdomain.com and see if you get the IIS 7.0 server multi-language single page splash screen.  If yes, then your TS Gateway setup is one step closer to working.
  • Enable all logging via the AUDITING tab.  These events will log to the Event Viewer in the area below.  This is extemely handy for troubleshooting things.

TS Gateway getting knocked offline due to IIS Restart

If you restart your IIS server at anytime, your TS Gateway service will get knocked offline.  As of June 27, 2010 this is a documented issue with Windows Server 2008 and later.

If you see an error in the TS Gateway event log that looks like this:

The TS Gateway service is shutting down. To diagnose possible causes for this problem, verify whether the following services are installed and started: (1) World Wide Web Publishing Service (2) Internet Authentication Service (IAS) (3) RPC/HTTP Load Balancing Service. Also, check Event Viewer for Network Policy Server (NPS) and IIS events that might indicate problems with NPS or IIS.

or if your client computer (laptop) that is trying to connect from the outside, gets an error like this

Remote Desktop Disconnected
----------------------------------------------
This computer can't connect to the remote computer.
Try connecting again. If the problem continues, contact the owner of the remote computer or your network administrator.

You need to go to the service manager and make sure the following services are started:

  • Terminal Services Gateway
  • RPC/HTTP Load Balancing Service
1 3 4 5