How To Use SSL To Secure Your Rails App Against e.g. FireSheep
kalzumeus.com
kalzumeus.com
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
It's been a year since I did that, but I think that's what I used to force the entire site into https only requests.[1] http://wiki.nginx.org/NginxHttpSslModule
[2] Add this to your config: server { listen 80; server_name example.com; rewrite ^/(.*) https://example.com/$1 permanent; }
You should also set the HttpOnly flag, which implements some XSS-limiting features, dependent on the browser.
While you're looking at securing session management, it's probably worth looking at Cross-Site Request Forgery:
http://www.owasp.org/index.php/Cross-Site_Request_Forgery_(C...
Some frameworks, such as Django have Cross-Site Request Forgery protection built in for free. The OWASP site linked earlier is an invaluable resource for all things web application security, and is definitely worth bookmarking.
Of course, there's no trivially installable exploit with a pretty UI that plugs into Firefox to do that yet, so it'll be at least another few years before anyone takes that attack seriously.
https://rails.lighthouseapp.com/projects/8994/tickets/5629-s...
And it has been further enhanced recently: http://github.com/rails/rails/commit/2d5a12a50bcd83fcc99865d...
def redirect_to_ssl
redirect_to :protocol => "https://" unless (request.ssl? or request.local?)
endAlthough it is trivial to implement SSL, you should only do it if you need to because of the above, using up all the IPv4 addresses because your random video sharing website might have a user somewhere on a wireless network where their cookies are hijacked. This attack has existed for pretty much ever and isn't very useful for a dedicated focused attack.
However just because you serve one site doesn't mean that you use one IP more, nor do you contribute to the exhausting of ipv4 addresses -- you already use your ip to connect to your server.
The problem is browser support isn't quite where it needs to be, with IE only supporting it in 7.0+ on Vista or later (IE 6 or IE anything running on Windows XP is out of luck).
1) SNI -- this has just too poor support at this time
2) Separate ports -- you can make make Apache listen on for example port 446 and use links like https://subdomain.foobar.com:446/.... -- however some corporate firewalls etc. may be blocking connections out on non-standard ports; we just that just for multiple testing environments. This still requires multiple certs or a wildcard cert.
3) Wildcard certs -- they are are usually quite bit more expensive but they'll let you register *.domain.com. So if a client wants a subdomain you can let them have client.yourdomain.com that way without multiple certs or IPs -- FogBugz uses that for example.
Also note that SSL doesn't really work with name based virtual hosts (Host:-header), so every site you enable SSL with requires its own IP address.
With addresses in general running out quickly, this might be a problem for you (or your host).
With larger SSL sites, it's not uncommon to use SSL accelerators and reverse proxy through to the HTTP servers at the back. It's definitely not cheap though.