Nginx basic authorization
This documentation set has been merged with the Maestro Version 2 documentation and is officially deprecated. These pages will be redirected to their equivalents in that doc set within the next few weeks.
You can use Cloud 66 CustomConfig to protect your application or parts of it with a username and password based on HTTP basic authentication. Follow the instructions below to accomplish this.
We’ll use htpasswd to create your password file - it encrypts it the password with MD5 encryption. Install it:
sudo apt-get install apache2-utils -y
Once that is installed, we’re ready to create your password file. We recommend that you create this file within your repository, which will be deployed to your servers. This command will prompt you to input a password.
sudo htpasswd -c <directory>.htpasswd <user_name>
Now we can go ahead and customize the Nginx configuration, which you can see more about in our Nginx CustomConfig documentation.
You will want to add the following code within the server section of your configuration. Where you put it will depend on which Rack server you are running, and whether or not you are using HTTPS traffic.
auth_basic "Restricted"; auth_basic_user_file /current/.htpasswd;
This will read your password file from your repository directory on the server. Once you save that configuration, it will apply immediately on your server.