Nginx forward all requests to https

Since listening to Mike West and reading his posts I finally decided to really move all my stuff hosted on my own server to SSL. Certs are really not that expensive anymore (about 9$ per Year) and getting more IPs for my server was easier than expected (Whats up with IPv4 depletion aye?).

Since I want everything reachable with all the old links I decided to forward pretty much everything to the ssl host, to do this via Nginx the following little config should work, so I wanted to share since it was not as easy as expected to actually get everything running nicely. It forwards in this case http://example.com http://www.example.com https://www.example.com all to https://example.com.

https://gist.github.com/1337018.js

To make sure the clients will only use SSL from now on the server serving SSL should furthermore have ” add_header Strict-Transport-Security “max-age=31556926; includeSubdomains”; ” somewhere in the config.

Thats it… now to move over more stuff.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s