Nginx Password Protect Entire Port Number 8081
Solution 1:
I'm assuming you have a separate server {
block for this port...so you'd just protect the /
directory from within that server block:
location / {
auth_basic "Restricted Area";
auth_basic_user_file conf/htpasswd;
}
So:
server {
listen 8081;
server_name whateveryouwant;
root /path/to/root/folder;
location / {
auth_basic "Restricted Area";
auth_basic_user_file conf/htpasswd;
}
}
I haven't tested this, but that's how it should look.