All,
I've seen several threads talking about SSL encryption for Drupal logins, but haven't found one outlining a complete and viable solution. I can't say that I've got a silver bullet for SSL logins (far from it), but I think I've got it working on my system. I'd like to share my setup in hopes that other people might derive related solutions. Of course, I'd also like feedback: I've been using Linux and Apache for less than a year, Drupal for only a few months, and I'm not even confident that I've actually implemented secure logins. I'd greatly appreciate any sanity checks, suggestions, criticisms, or best practices that people want to offer.
This gist of my approach uses mod_rewrite to redirect users into secure "https://" pages when they're submitting sensitive information, and automatically bring them back to plain "http://" pages when they resume less critical activities. This involves the normal Apache tricks, plus (at least in my case) running parallel http and https Drupal sites from a common codebase and database, and also moving Drupal's clean url rules out of the default .htaccess file.
With that said, I have taken the time to compose a "formal-ish" write up of my setup. If this works for people, I can keep updating it as I learn more, as Drupal changes, etc. Here we go...
1) Goals
- I wanted SSL encryption for transactions involving logins, passwords, and personal information; I did not want to host the entire site in an encrypted (https) space
- In addition to logins, I wanted a solution that encrypted administrative pages where logins and passwords can be set or changed.
- I wanted the solution to work with multisite Drupal installations (specifically unique sites with unique hostnames and databases)
- I wanted the solution to work with and without Drupal's clean URLs
2) Assumptions
- Apache is up and running with mod_ssl and mod_rewrite installed, enabled, and configured
- Apache is listening for traffic on both http and https ports (usually 80 and 443; different in my case, described below)
- You have write access to Apache's httpd.conf (I'm self-hosting; I can't speak to hosted situations)
3) Complications
Half the machinations that follow wouldn't be necessary--or would be greatly simplified--if I had unrestricted inbound traffic to my server. As it is...
- My ISP blocks incoming traffic to port 80, so:
- Normal http traffic (port 80) is redirected through dyndns.org and arrives to my server as "http://myhostname.dyn.mydomain.com:8080"
- Encrypted https traffic (port 443) is not blocked and thus not redirected; it arrives to my server as "https://myhostname.dyn.mydomain.com"
-
Note that the visible ":[port]" isn't required here: the server expects--and can get--incoming traffic on the default https port
4) Test Setup
5) Drupal Configuration