I have a few personal websites running in an ubuntu VPS and I got tired of having to copy + paste my password when editing nginx config files. So, I created /home/myUserName/www/ and created subdirectories for each website's assets, including the nginx config files, then I symlinked the config files into /etc/nginx/sites-available/. This makes editing the config files, along with each site's assets, much less of a hassle as I don't have to authenticate as root each time I edit the files.

What are the security implications regarding doing things this way? The nginx config files don't have any sensitive info in them, other than specifying the location & existence of ssl certs for the webpages. Must nginx config files be only writable by root, when I'm the only person using the system? Why should't I do things this way?


Practically speaking the security implications of this are low to high severity, depending on your setup and other configurations you have.

The primary benefit of root ownership is that it is usually more secure than user or system accounts on virtue of not having many programs running with this privilege.

If your user account has write access to the nginx config you are opening up yourself to a range of potential issues:

  • If your user account uses password authentication you might be open to password leaking.
  • If you run software under your user account rather than a less privileged system account then security issues in those software can potentially allow attackers to modify your nginx configuration files.

If attackers can modify your nginx configuration file they can easily take your website offline by writing an invalid configuration file. (requires nginx restart though)

Additionally, depending on the plugins installed they might be able to write advanced custom logic to write files to disk. This would allow them to install backdoors to further compromise the server.

So if you want to give your user account access to your nginx config, then make sure to take the following precautions to minimise risk:

  • Use ssh keys to authenticate with your server.
  • Don't run any public software under your user account, use a less privileged system user instead.
  • As of now, ssh keys are the only way to authenticate & nginx can only be restarted by root or a sudoer, but the webapp itself is owned by my user account. I think I will revert the config files to the standard setup, and possibly create a system account to run the app itself, which is something I hadn't considered. Cheers! – jakks0 Oct 9 '20 at 3:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.