Live data from Hacker News

Digital Ocean: Ubuntu, Nginx, Unicorn, Rails

blog.mccartie.com

41–49 of 49 posts

Re: Digital Ocean: Ubuntu, Nginx, Unicorn, Rails

#41

Quick question; I don't know much about setting up a Linux server but I found it interesting the post had nothing related to security besides setting up a ssh key and separate user for deployment. What security-related tasks do you do when setting up a new server? Besides the above, the only things that come to mind for me are: 1. Change ssh port from default. 2. Block unwanted traffic via iptables. 3. Protect ssh wi…

Some very basic security:

1. Change SSH port

2. Block all password logins

3. Disable root login (namely, a non-root user must login via a key, then su or sudo to root)

4. Lock down everything with IPTables

5. Allow only encrypted connections to the few ports open via IPTables (normal exception is port 80 for http).

6. Segment the network (with DO private networking your machines are open to anyone within the same facility, so you need to isolate your private network from other DO customers)

7. Lock down each running service/daemon per it's standard configuration. For example, if you're running Postgres, then lock it down per pg best practices.

8. Create individual, non-privileged users for each service that you're starting. ex. If you're running an app server, then it should have its own user.

9. Sandbox everything that can be.

10. Turn off everything that is not being used, then uninstall it.

11. If you don't need them, then uninstall build tools such as compilers. Have a separate build machine.

12. Only open edge of network machines to the outside world. On DO, turn off eth0 on all machines that customers do not directly interact with.

13. All services that are internal user only should have public networking totally disabled. Ex. Redis should only run on a private IP, should have the public interface disabled, and should only be accessible via a secure connection (ideally with some type of true authentication, replay protection, etc. Or, just run these services on a trusted network and pray that nobody penetrates your network deep enough to find out that you're totally unprotected once inside your network.

14. Don't keep private keys/certs in places that they are not needed.

15. Have a map of each service, the user that it runs under, what resources that user has access to, and a general map of what sequence someone has to follow to control your network. If you catch someone mid-attack, you can start to lock off parts of your network.

16. Logging! And monitor them for attacks. And ship logs off the machine in question so that you can review logs even if a machine is compromised.

There's lots more, but this is a basic list that should be configured via Ansible/Chef/Puppet/Salt for each box.

One other item I've heard is that some people like to run heterogeneous networks.

Re: Digital Ocean: Ubuntu, Nginx, Unicorn, Rails

#42
post #37
post #31

Earlier quoted context omitted.

That's why I picked Ansible. The only dependency is SSH, and you can write modules in whatever language you choose. Plus -- and this is a big win -- Ansible actually has usable documentation and practical examples, which coupled with a really clean design, make it way easier to get developers up to speed on the operations half of things.

Can you recommend tutorials, examples for Ansible? Is Ruby knowledge required to efficiently use Ansible? I would like to automate the installation of nginx, php, nodejs, mysql, etc. incl. modify a few config files.

Ansible is written in Python, so no you don't need Ruby knowledge, and I've found the documentation -- especially the tutorials -- to be very helpful: http://docs.ansible.com/intro.html

Re: Digital Ocean: Ubuntu, Nginx, Unicorn, Rails

#43
post #37
post #31

Earlier quoted context omitted.

That's why I picked Ansible. The only dependency is SSH, and you can write modules in whatever language you choose. Plus -- and this is a big win -- Ansible actually has usable documentation and practical examples, which coupled with a really clean design, make it way easier to get developers up to speed on the operations half of things.

Can you recommend tutorials, examples for Ansible? Is Ruby knowledge required to efficiently use Ansible? I would like to automate the installation of nginx, php, nodejs, mysql, etc. incl. modify a few config files.

Ansible is mostly configuration based - Ansible itself is written in python but all you'll typically need to write for most usages is configuration in YAML. So no ruby at all.

There are likely existing roles for most things at http://galaxy.ansible.com/

The Ansible docs at http://docs.ansible.com/ are pretty good, and there are lots of getting started guides most weeks on the Ansible weekly mailing list (https://devopsu.com/newsletters/ansible-weekly-newsletter.ht...)

And there are a few pages on my github blog on a few fundamental principles of modelling configuration e.g. http://willthames.github.io/2014/03/17/ansible-layered-confi... http://willthames.github.io/2014/04/02/modelling-credentials... to give a bit of flavour of how to manage more complicated setups. Installing things is easy, getting the configuration right for your needs is the tricky bit!

Re: Digital Ocean: Ubuntu, Nginx, Unicorn, Rails

#45
post #36

I heard Ansible over SSH is good to automate the installation. Has some experience with it? I am interested in a good tutorial similar to OP's article.

Have you looked at these? https://www.digitalocean.com/community/tutorials/how-to-crea... + https://www.digitalocean.com/community/tutorials/how-to-inst...

Thanks for sharing! Great that DigitalOcean has many useful tutorials.

The tutorial doesn't touch the "replace" command (http://docs.ansible.com/replace_module.html), that seem to be useful to modifying existing config files.

Re: Digital Ocean: Ubuntu, Nginx, Unicorn, Rails

#46

Quick question; I don't know much about setting up a Linux server but I found it interesting the post had nothing related to security besides setting up a ssh key and separate user for deployment. What security-related tasks do you do when setting up a new server? Besides the above, the only things that come to mind for me are: 1. Change ssh port from default. 2. Block unwanted traffic via iptables. 3. Protect ssh wi…

Some very basic security: 1. Change SSH port 2. Block all password logins 3. Disable root login (namely, a non-root user must login via a key, then su or sudo to root) 4. Lock down everything with IPTables 5. Allow only encrypted connections to the few ports open via IPTables (normal exception is port 80 for http). 6. Segment the network (with DO private networking your machines are open to anyone within the same fac…

Thank you so much for all that. I took a great introductory Linux course by the Linux Foundation over at edx[0] which really filled me in on a lot of stuff about Linux one misses out on when they learn on their own. Sadly, the subsequent Linux Foundation training courses are way out of my price range. Even the intro course offered I took for free on edx is offered by the Linux Foundation for thousands of dollars.

The good thing is I can mostly learn stuff on my own but have a hard time figuring out what I should be learning. Your comment helps a lot on that department. Even if I don't quite understand how to do some of the stuff your saying e.g. segment the network? Sandbox? Isn't eth0 my primary port to connect to my server? Which logs should I be monitoring (I've only heard of auth.log)?

Thanks.

[0] https://www.edx.org/course/linuxfoundationx/linuxfoundationx...

Re: Digital Ocean: Ubuntu, Nginx, Unicorn, Rails

#47

Would love to see a part two of this, for when you app gets popular... covering three simple (but perplexing for beginners) things: 1) dedicated database server 2) two application servers 3) git push to multiple application servers

Great idea, thanks!

Re: Digital Ocean: Ubuntu, Nginx, Unicorn, Rails

#49
post #48

> sudo apt-get install nginx no, the ubuntu repository is outdated, you should add the nginx team ppa: sudo add-apt-repository ppa:nginx/stable now you can 'sudo apt-get install nginx'

Another potential repo:

https://launchpad.net/~chris-lea/+archive/ubuntu/nginx-devel

Post reply on HN