I successfully used this tutorial: http://techbot.me/2010/08/deployment-recipes-deploying-monitoring-and-securing-your-rails-application-to-a-clean-ubuntu-10-04-install-using-nginx-and-unicorn/ for our ruby on rails server.
but I wonder if this installation is safe. what troubles me is that the same user "deployer", who is a sudoer, is running the application.
doesn't this open the possibility that by some form of code injection an attacker gets full access to the system (opposite to a common apache installation where the apache process runs as say www-data)?
In general, having the
deployer
user insudoers
doesn't necessarily mean an attacker is automatically root; the attacker will still need to runsudo
to escalate from thedeployer
account.You will be safer by requiring a password for
deployer
to runsudo
. You will be even safer if you restrict the commands thatdeployer
can run withsudo
to what's actually required than "everything", e.g., ifdeployer
hassudo
privs only so that it can reload nginx, then you can remove it from the "staff" group, and then add in a line to/etc/sudoers
like:Please see
sudo
documentation for more details.As a side note, the document you're looking at looks more like a basic deployment guide, rather than a "securing your site" guide. Take a look at, for example, this RubyConf talk for something more security specific.