Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Good for starters but there are quite a few bad practices used in this tutorial such as declaring your apps templates directory when by default Django searches all apps for a templates directory. Also running nearly everything as root.

This will get you up and running but just be aware that some of the items may not be the "correct way" of doing it.



>>such as declaring your apps templates directory when by default Django searches all apps for a templates directory.

I don't think so. Removing the templates directory gives you an exception. Maybe you are using another loader?

>>Also running nearly everything as root.

Right, this was meant for starters so I didn't want to complicate things. But I just added some options so now Upstart will run GUnicorn under other user.


What do you suggest is the correct way? Running each app under its own user with groups for each resource?


The correct way on Linux to run services is for each service to have it's own user. If you are just going to be running a single Django project I recommend creating a user simply called "django", putting all the projects files in "/srv/www/" because that's what "srv" is for. And then running your django project as the django user. If your django project gets hacked and you have permissions set properly then the most they can do is fiddle with all your django files. If they have root access they can get your SSL certs, SSH keys, redirect your Nginx server and all kinds of other bad things.


Sure, trying to mitigate damage with sandboxes is a good goal, but the reality is that if your server is hacked at all you're screwed. There is enough local shell exploits that once you are on a box, chances are you can get past user and group permissions pretty easily. Plus, they've hacked your box! Time to wipe it and start over. Period.

As for SSL certs, don't you store those on the load balancer? If you are running a single box and it goes down, pointing the LB at a new backend box is a lot easier than copying certs around.

As for SSH keys, I'm not quite sure what damage could be done there. The only thing on there is public keys, right?

As I said below, this is a big reason why I believe in PaaS if your application can deal with it (and most can). Sysadmin has become so commoditized that there is no point in wasting your own time/money dealing with this stuff.


>> Also running nearly everything as root.

Not really. It seems everything runs from a virtual environment under the Ubuntu user which is not root btw.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: