We have seen how to use the features available in the Apache .htaccess
file that HTML5 Boilerplate comes with. But there is a repository of configuration files for other kinds of servers such as Ngnix, Node, Google App Engine, IIS, and Lighttpd. The following table contains the configuration filenames and their corresponding server software:
Config filename |
Server software |
---|---|
|
Apache Web server at |
|
IIS Web server from |
|
Node Web server from |
|
Ngnix server at |
|
Lighttpd server at |
|
Google App Engine at |
The configuration files for these servers are available at github.com/h5bp/server-configs
.
HTML5 Boilerplate's web.config
file is used to configure options for your site running on an IIS7 server or higher.
As with the .htaccess
file, merely having it in the root folder of your website allows it to be recognized and used to configure an IIS7 server.
As with the other configuration files, place it in the root folder for the Lighttpd server to configure the server.
Nginx is a lightweight server popular with websites using the Ruby on Rails framework.
As with the .htaccess
file, place this file in the root folder of your website. In addition, make sure nginx-mime.types
is also in the root folder. This file is required for Ngnix to make sure it sends each file with the right MIME type.
With the node.js
configuration file, the usage is different. The configuration file assumes you are using the Express/Connect framework for managing resource requests for your app. In your server-side app code, you can use the following to start the server:
var h5bp = require('h5bp'), var app = express.createServer(); app.use(h5bp.server()); app.listen(3000);
This requires you to install the h5bp
package using Node Package Manager (NPM) and the express
package using the same. The h5bp
package has a slew of configurations that will be used when the server is started. If you wish to use only some specific configurations, you can pass them in as options to the server function, as shown in the following code snippet:
app.use(h5bp.server({ server: true, setContentType: true, removeEtag: true });
Some websites are also served from Google App Engine (http://code.google.com/appengine/), which requires your website's backend to be written in Java, Python, or Go.
You need to ensure that the app.yaml
file is in the root folder of your website.
The following table contains the summary of all the features available in HTML5 Boilerplate server configurations:
Feature name |
Apache |
Nginx |
IIS |
Lighttpd |
Node.js |
Google App Engine |
---|---|---|---|---|---|---|
ETags |
Yes |
Yes |
Yes |
Yes |
No |
No |
Gzip |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
Expires header |
Yes |
No |
No |
No |
Yes |
No |
Custom 404 page |
Yes |
Yes |
Yes |
No |
No |
No |
Forcing the latest IE version |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
Using UTF-8 encoding |
Yes |
Yes |
Yes |
No |
No |
No |
Serving the right MIME types |
Yes |
Yes |
Yes |
Yes |
No |
Yes |
Blocking access to hidden folders |
Yes |
No |
No |
No |
Yes |
No |
Blocking access to backup and source files |
Yes |
No |
No |
Yes (only |
Yes |
No |
Stop advertising server information |
No |
No |
Yes |
No |
Yes |
No |
Starting Rewrite Engine |
Yes |
No |
No |
No |
No |
No |
Preventing 404 errors for non-existing redirected folder |
Yes |
No |
No |
No |
No |
No |
Suppressing or forcing the "www." at the beginning of URLs |
Yes |
No |
Yes |
No |
Yes |
No |
Setting cookies from iFrames |
Yes |
No |
Yes |
No |
No |
No |
PHP security defaults |
Yes |
No |
Yes |
No |
No |
No |
Stop advertising Apache version |
Yes |
No |
No |
No |
No |
No |
Allowing concatenation from within JS and CSS files |
Yes |
No |
Yes |
No |
No |
No |
Stopping screen flicker in IE on CSS rollovers |
Yes |
No |
Yes |
No |
No |
No |
Preventing SSL certificate Warnings |
Yes |
No |
Yes |
No |
No |
No |
Cross-domain AJAX requests |
Yes |
No |
Yes |
No |
Yes |
No |
CORS-enabled Images |
Yes |
No |
No |
No |
No |
No |
Webfont Access |
Yes |
No |
No |
No |
No |
No |