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
  • 7
  • M/Monit already requires authentication to get to its management and monitoring page. Are you trying to get nginx to do the same thing? – ewwhite Feb 06 '16 at 14:18
  • @ewwhite, you talking about the login page? cause I meant protecting it as you would protect a folder access – Jadeye Feb 06 '16 at 14:43
  • Just place this `server` block in the `default` conf file and got the following error: `bind() to 0.0.0.0:8080 failed (98: Address already in use)' – Jadeye Feb 06 '16 at 14:58
  • `$netstat -tulpn = tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 6303/mmonit ` – Jadeye Feb 06 '16 at 14:59

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
  • 7