I'm hosting the server on a vanilla ubuntu box from DO, so I've read into disabling root ssh access and removing ssh password authentication. I'm using nginx as a proxy, but I'm not sure if there is work I need to do there as well.. I'm currently working on setting up https connections, but any other pointers and ideas would be much appreciated!
Not strictly from a Django perspective, but general web apps. I have tried it, tested it, and used it in production; however, remember, security is something very specific. My solution can't work the same with yours, so consider hacking this for your purposes.
With that said, let's get into it.
Decouple Networking Infrastructure
We all love to decouple our applications into smaller pieces. I have found that decoupling networking infrastructure into bits and pieces really helps with scaling, and secures your application.
Topology
Topology is your virtual data center fabric. I do two things here:
Design
That being said, it's usually really helpful if you think of something on paper and then try to find vulnerabilities; patch them up, and, in the end, you get a somewhat secure setup (in security, nothing is 100% secure.)
Encryption and Backup
If you're storing sensitive data, it's a good idea to set up deferred encryption; this sort of encryption is unobtrusive, meaning that it's done once every day/week/month at a specific time with little or no load on your primary databases, and secures all of the data.
You can setup backup the same way.
Machine Type
(copying from one of my previous answers)
For databases/caches I use storage-optimised machines. The principle I follow is rather simple:
If you're on Amazon AWS, I wouldn't recommend EBS. I use I2 -- High I/O Instances.
.xlargeserves almost everything.Transport Layer Security (TLS)
Ah, cryptography. My favorite subject ( @JanVladimirMostert will vouch for me about how interesting it can get :D )
Setting up
dhparamsThis is the
Diffie-Hellman groupparameter. For the non-crypto-enthusiasts here, thedhparamis used for Diffie-Hellman Key Exchange mechanism. Very simply put, any person intercepting the traffic, seeing everything, can't derive the key the two parties have generated. Pretty cool.So, for that, you need some "clean" DH-Parameters. "Clean" as in, generated by you. Now, this takes time, so you might want to wait for it. You can generate a secure param using
openssl dhparam -out ~/Desktop/dhparam.pem 4096then copying that
dhparam.pemfile to your server, and using it.Cipher Suite
The cipher suite defines what the browser will use for TLS. It usually consists of the following components:
DHfor Diffie-Hellman;RSAfor authentication;AES-128for encryption;SHA-1for message/digests.The cipher suite will be
DH-RSA-AES128-SHA1.To get the best possible security, I'd recommend the following suites
ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS. This has been formatted fornginx, so you can just add assl_cipherstag with this suite-set within your server block, and you're ready.Protocol Versions
SSL 3- (< 3) have been exploited. See the POODLE attack. The set of protocols I'd recommend is
TLSv1 TLSv1.1 TLSv1.2which you can add in yournginxsetup usingssl_protocols TLSv1 TLSv1.1 TLSv1.2;within the server block.HTTP Strict Transport Security
HSTSIt means that the user won't go on
HTTP. Add it withadd_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";Firewalls
Consider using firewalls. I can't write a long thing here, as it's really, really specific.
Conclusion
I'd love to help you implement this, should you wish! If you want more advice, feel free to contact me. :)