phymooc / learn-linux

0 stars 0 forks source link

authbind (use 80 port with non root) #2

Open phymo opened 2 years ago

phymo commented 2 years ago
  1. CentOs: wget https://s3.amazonaws.com/aaronsilber/public/authbind-2.1.1-0.1.x86_64.rpm
  2. sudo rpm -Uvh authbind-2.1.1-0.1.x86_64.rpm
  3. config byport 80
    sudo touch /etc/authbind/byport/80
    sudo chown irteam /etc/authbind/byport/80
    sudo chmod 755 /etc/authbind/byport/80
  4. add line in .bashrc: alias pm2='authbind --deep pm2', then run source ~/.bashrc
phymo commented 2 years ago

config pm2 auto restart with authbind when reboot:

  1. pm2 startup to create systemd service.
  2. add authbind in service
    # edit pm2-user.service,
    +ExecStart=/usr/bin/authbind --deep /home/deploy/.nvm/versions/node/v8.9.0/lib/node_modules/pm2/bin/pm2 resurrect
    +ExecReload=/usr/bin/authbind --deep /home/deploy/.nvm/versions/node/v8.9.0/lib/node_modules/pm2/bin/pm2 reload all
    +ExecStop=/usr/bin/authbind --deep /home/deploy/.nvm/versions/node/v8.9.0/lib/node_modules/pm2/bin/pm2 kill
    -ExecStart=/home/deploy/.nvm/versions/node/v8.9.0/lib/node_modules/pm2/bin/pm2 resurrect
    -ExecReload=/home/deploy/.nvm/versions/node/v8.9.0/lib/node_modules/pm2/bin/pm2 reload all
    -ExecStop=/home/deploy/.nvm/versions/node/v8.9.0/lib/node_modules/pm2/bin/pm2 kill
  3. enable service
    sudo systemctl daemon-reload
    sudo systemctl enable pm2-user.service
  4. restart server to test: sudo /sbin/reboot