Welcome to Centmin Mod Community
Register Now

Nginx Nginx permission for root user sftp uploads

Discussion in 'Install & Upgrades or Pre-Install Questions' started by Benjamin74, Apr 3, 2017.

  1. Benjamin74

    Benjamin74 Member

    76
    7
    8
    May 2, 2016
    Ratings:
    +18
    Local Time:
    7:06 AM
    Sorry to ressurect this thread but I just wanted to be sure that I'm not doing anything bad ;-)

    Is it OK to use a CRON to set ownership as nginx:nginx to the entire /home/nginx/domains/ folder ??


    Or should the permissions be only set to the "public" folder (i.e. for each domain) ?

    Thanks,
     
  2. rdan

    rdan Well-Known Member

    5,447
    1,408
    113
    May 25, 2014
    Ratings:
    +2,201
    Local Time:
    2:06 PM
    Mainline
    10.2
    Yes I think.
     
  3. Sunka

    Sunka Well-Known Member

    1,150
    325
    83
    Oct 31, 2015
    Pula, Croatia
    Ratings:
    +525
    Local Time:
    7:06 AM
    Nginx 1.17.9
    MariaDB 10.3.22
    Yes you can. I have that for a year and half.
    Code (Text):
    */5 * * * * /usr/bin/chown -R nginx:nginx /home/nginx/domains
     
  4. eva2000

    eva2000 Administrator Staff Member

    54,927
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    4:06 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    As per Step 2 of Getting Started Guide this would only allow to root user uploads via sftp. Any uploads via pure-ftp virtual ftp user are already owned by nginx user/group.

    take a read of thread in Centmin Mod Insights forum at https://community.centminmod.com/th...kup-restore-file-directory-permissions.10633/

    if you setup tools/backup-perm.sh script via cronjob for each nginx vhost site, it auto does the nginx chown recursively on each /home/nginx/domains/domain.com vhost directory. Setup one tools/backup-perm.sh script per nginx vhost at /home/nginx/domains/domain.com/tools/backup-perm.sh as the script only works on per nginx vhost basis

    tools/backup-perm.sh first backs up file and directory permissions at /home/nginx/domains/domain.com and any files/directory under that and then chown nginx recursively for /home/nginx/domains/domain.com and files/directory under that
     
  5. Benjamin74

    Benjamin74 Member

    76
    7
    8
    May 2, 2016
    Ratings:
    +18
    Local Time:
    7:06 AM
    Ohhh I think I get now why I have to run this chown command, it's not because of pure-ftpd edits I'm making but because of SSH root edits !!

    Because I'm uploading with a pure-ftpd user that has access to all domains:

    pure-pw useradd mycustomusername -u nginx -g nginx -d /home/nginx/domains/

    so pure-ftp uploaded files should be good, but I'm sometimes doing some small edits or wget from the root ssh command line which are likely to cause issues later on if I don't chown them...
     
  6. eva2000

    eva2000 Administrator Staff Member

    54,927
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    4:06 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  7. Benjamin74

    Benjamin74 Member

    76
    7
    8
    May 2, 2016
    Ratings:
    +18
    Local Time:
    7:06 AM
    Yep saw the script. Since I just need a brutal chown accross all domains, I prefer the simple crontab -e with chown -R nginx:nginx /home/nginx/domains since it seems to be working just fine ;-)
     
  8. eva2000

    eva2000 Administrator Staff Member

    54,927
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    4:06 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    yeah that's what my script does just it backups up directory and file permissions before doing chown so you can restore directory and file permissions if needed