title: Nginx M/Monit password protect
body: <p>I am trying to protect access to M/Monit web interface:<br />
  <strong>Box:</strong><br />
  ubuntu 14.04<br />
  nginx 1.8.1<br />
  mmonit-3.5.1</p>
  
  <p>I created a mmonit config file under <code>/etc/nginx/sites-available</code>:<br /></p>
  
  <pre><code>server {
          listen 8080;
          root /var/www/html;
          location / {
                  auth_basic "Restricted Content";
                  auth_basic_user_file /etc/nginx/.htpasswd;
          }
  
          location ~ /\.ht {
                  deny all;
          }
  
  }
  </code></pre>
  
  <p>It does not display the authentication dialog.
  I followed <a href="https://serverfault.com/questions/620735/nginx-password-protect-entire-port-number-8081">serverfault-Nginx Password Protect Entire Port Number 8081</a>, but it seems I am getting something done wrong...I am new to nginx.</p>
  
  <p>Anyone has an idea how to go about it?
  Should it be in the same <code>default</code> server config file?
  Cheers</p>