Authentication with NGINX
While many CMSes and advanced web applications have their own authentication systems, we can use NGINX to provide a second layer. This can be used to provide multifactor authentication and also to limit brute force attempts.
Alternatively, if you have a very basic application or a system, such as Elasticsearch, without any authentication, NGINX is a natural fit to provide for this role.
Getting ready
This recipe assumes that you have an existing web application. This could be as simple as static pages or a full CMS such as WordPress.
We'll also need to install Apache utilities (not the full web server), which is generally packaged as apache2-utils
on Debian/Ubuntu-based systems and httpd-tools
on CentOS/RedHat-based distributions.
How to do it...
In order to provide basic authentication, we first need to create a password file. We can do this with the htpasswd
utility, which is part of the Apache tools. It's important that we don't store this file in a publicly accessible...