Install Nginx and password generator
opkg update
opkg install nginx openssl-util
Create a file to store password
touch /etc/nginx/.htpasswd
Generate password for user
echo -n 'USERNAME:' >> /etc/nginx/.htpasswd
openssl passwd -apr1 >> /etc/nginx/.htpasswd
cat /etc/nginx/.htpasswd
Edit server configuration
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
server_name localhost;
location / {
try_files $uri $uri/ =404;
auth_basic "Restricted Content";
auth_basic_user_file /etc/nginx/.htpasswd;
}
}
Make it effective
service nginx restart