0

I am trying to protect access to M/Monit web interface:
Box:
ubuntu 14.04
nginx 1.8.1
mmonit-3.5.1

I created a mmonit config file under /etc/nginx/sites-available:

server {
        listen 8080;
        root /var/www/html;
        location / {
                auth_basic "Restricted Content";
                auth_basic_user_file /etc/nginx/.htpasswd;
        }

        location ~ /\.ht {
                deny all;
        }

}

It does not display the authentication dialog. I followed serverfault-Nginx Password Protect Entire Port Number 8081, but it seems I am getting something done wrong...I am new to nginx.

Anyone has an idea how to go about it? Should it be in the same default server config file? Cheers

Jadeye
  • 123

1 Answers1

1

So I figured it out...
(This is under default server config)

root /var/www/html/;
server_name localhost;

location /mmonit/ {
    proxy_pass http://yourServerIp:8080/;
    auth_basic "Restricted Content";
    auth_basic_user_file /path/to/your/password/file/;
    index index.csp;
}

ln -s /path/to/your/mmonit/folder/ /var/www/html/
Gives: mmonit -> /path/to/your/mmonit/folder/

Now point you browser at: http://yourServerIp/mmonit/
And you will have the 'Authentication Required' dialog box!
A username and password are being requested by http://yourServerIp. The site says: "Restricted Content"

**I do suggest calling the link something else then mmonit....to you choice.
Any wayz your access is now double protected!

Jadeye
  • 123