Authentication HTTP Nginx

Fuentes


su -
yum install -y httpd-tools

cd /etc/nginx/

# Donde el nginx es el nombre que después pedirá
# y .htpasswd el archivo que generara.
htpasswd -c /etc/nginx/.htpasswd nginx

Editar en el servidor:

vim /etc/nginx/conf.d/archivo_configuracion.conf

server {
    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  _;
    root         /usr/share/nginx/html;

    auth_basic "Private Property";
    auth_basic_user_file /etc/nginx/.htpasswd;

    # ....
systemctl reload nginx