An nginx configuration for security
tautt.com
tautt.com
> add-apt-repository ppa:nginx/stable
I don't think this is a good idea. It's a bit unclear on their wiki[1] but they have an official repository maintained by nginx.org deb http://nginx.org/packages/ubuntu/ lucid nginx
deb-src http://nginx.org/packages/ubuntu/ lucid nginx
(substitute your Ubuntu version for lucid, obviously)and separately the PPA you're using but "this PPA is maintained by volunteers and is not distributed by nginx.org." How committed are those volunteers? Do you want to find out on your server?
The official repository carries nginx 1.4.2 (I use it with raring) which works with at least TLS 1.1 (that's what Chrome tells me about the connection).
EDIT: Qualsys gives my setup an A, with a pat on the back for supporting forward secrecy and a warning that I'm vulnerable to the BEAST attack. Apparently, I also support TLS 1.2, what do you know.
[1] http://wiki.nginx.org/Install#Official_Debian.2FUbuntu_packa...
Thanks for the contribution
* !RC4 - RC4 is in doubt[1]. The only reason to keep it around was to mitigate the BEAST attack, which is now mitigated[2] client side, so RC4 should be dropped.
* gzip off; - Explicitly disable gzip compression to avoid BREACH[3]
* Ensure TLS deflate is off to mitigate CRIME[4] (this is the default in most, but not all combinations of nginx/OpenSSL).
* openssl ciphers -v is great for testing what ciphers match your settings.
* Comment your nginx config! You will not remember all of this when you next look at it (or someone else does). And some of it will certainly be outdated. Security is not a static game.
[1] http://www.theregister.co.uk/2013/09/06/nsa_cryptobreaking_b... [2] https://community.qualys.com/blogs/securitylabs/2013/09/10/i... [3] http://en.wikipedia.org/wiki/BREACH_%28security_exploit%29 [4] http://en.wikipedia.org/wiki/CRIME_%28security_exploit%29
You don't have to disable gzip entirely. Just on any URLs where an attacker could influence the contents of the response. If you serve all your static assets out of their own location block, feel free to enable gzip there.
Besides that, I assume people will use nginx 1.3.7 or newer, so a few defaults are assumed as well.
If you are using centos or any redhat related product you will have to build your own openssl to get 1.0.1 with perfect-forward-secrecy (the IUS repository does NOT include EC ciphers either). RedHat decided EC ciphers have patents that are valid (they are not).
The example configuration is missing ocsp stapling.
Their configuration is also including the root certificate in the download for every connection which is unnecessary.
Using RC4 over AES for beast mitigation is no longer considered optimal, if anything RC4 is not 100% trustworthy anymore. Lean on elliptic-curve ciphers with AES over RC4 for modern browsers. As a bonus you get CPU acceleration for AES on most servers and many newer home computers.
The RC4 part is based on this article https://community.qualys.com/blogs/securitylabs/2013/08/05/c.... But I will do some more research and update the post.
https://community.qualys.com/blogs/securitylabs/2013/09/17/u...
And the qualys SSL analyzer no longer penalizes for not mitigating Beast, they just warn about it in orange but there is no longer a penalty as of a couple weeks ago.
To start understanding the magic list of ciphers, enter the list into openssl like this and watch what it produces:
openssl ciphers -V 'RC4'
openssl ciphers -V 'EECDH+aRSA+RC4 EECDH EDH+aRSA !aNULL !eNULL !LOW'
(etc. etc.)take away some of the adds/exclusions in the list and watch what they add/remove. Plug in other people's lists and see what they do.
Then learn what ECDHE vs DHE means (and why DHE is slower)
Then learn about RSA vs DSA keys, EC ciphers etc.
Then play around with this tool that shows you what ciphers different browser support (try it with IE8 vs Firefox vs Chrome, etc) https://cc.dcsec.uni-hannover.de/
Then read about AES hardware acceleration in openssl on most modern processors (not all but many). http://zombe.es/post/4078724716/openssl-cipher-selection
and eventually, a few days later, you'll start to understand what is best :-)
It is always much more than a few lines in a configuration file if you really want to understand.
I know I'm not the only one with half a dozen, a dozen, or dozens of web servers I am responsible for -- who realistically isn't going to keep track of what the current consensus is and go updating the ssl configuration even every six months.
add_header Strict-Transport-Security max-age=31536000;
add_header X-Frame-Options DENY;
The first one tells browsers it should never try to visit the http version of this site, even if the user clicks on a http link the browser will visit the https version. This helps prevent ssl stripping attacks.The second prevents browsers from including this site in an iframe or frame, which helps prevent clickjacking attacks. If your site depends on those you can also set the option to SAMEORIGIN.
https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Option... https://developer.mozilla.org/en-US/docs/Security/HTTP_Stric... https://en.wikipedia.org/wiki/SSL_stripping#SSL_stripping
(I still would like to be able to zoom, but that's like asking for two ponies, and even getting one pony is far better than I could reasonably expect. Kudos!)
Nginx is indeed one of the easiest programs to compile, very light and fast to build.
Building the newest openssl from scratch for centos into an rpm is quite a workout. I had to read two guides and still had to play with it a bit to get everything just right. Oh and pro-tip from a big "duh" moment - don't try to remove old openssl on a SSH connection. It doesn't just run from memory, when it goes away, so does your connection to the server.
If you don't know what each line of a config that is being spoon-fed to you off of some website is doing, you're doing it wrong. Research everything!
http://wiki.nginx.org/HttpSslModule#ssl Note that since nginx version 0.7.14, the standard way to enable SSL is through the listen directive
There is a good amount of irony here. The most secure system is a system that you can't access at all.
;)
Seriously though, any "best for security" article should be taken with a huge grain of salt as security isn't something static that's the same everywhere.