Skip to content

Instantly share code, notes, and snippets.

@nfourtythree
Last active December 10, 2020 17:20
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nfourtythree/e9345dd673808dc7445eae56f7d58c5b to your computer and use it in GitHub Desktop.
Save nfourtythree/e9345dd673808dc7445eae56f7d58c5b to your computer and use it in GitHub Desktop.
Password Protect Serverpilot App

How to password protect your Serverpilot app

This is a quick (rough) guide on how to protect a Serverpilot pilot app with auth basic

1. SSH into your Serverpilot Server

ssh SERVERPILOTUSERNAME@your.server.ip.address

2. Create a htpasswd file in your app

htpasswd-sp -c ~/apps/APPNAME/.htpasswd desired_username

3. Login as root user

(you will be asked for your root password)

su

4. Move the nginx conf file (this stops Serverpilot overwriting your changes)

mv /etc/nginx-sp/vhosts.d/APPNAME.d/main.conf /etc/nginx-sp/vhosts.d/APPNAME.d/main.custom.conf

5. Open up the config file for editing

nano /etc/nginx-sp/vhosts.d/APPNAME.d/main.custom.conf

6. Add the following lines between the Location braces

auth_basic "Restricted";
auth_basic_user_file /srv/users/SERVERPILOTUSERNAME/apps/APPNAME/.htpasswd;

7. Restart nginx service

You must be logged in as root to do this

service nginx-sp restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment