title: Nginx Basic Auth not Working
body: <p>I am trying to passwoard protect the default server in my Nginx config.  However, no username/password dialog is shown when I visit the site.  Nginx returns the content as usual.  Here is the complete configuration:</p>
  
  <pre><code>worker_processes 1;
  
  events
  {
      multi_accept on;
  }
  
  http
  {
      include       mime.types;
      sendfile           on;
      tcp_nopush         on;
      keepalive_timeout  30;
      tcp_nodelay        on;
      gzip  on;
  
      # Set path for Maxmind GeoLite database
      geoip_country /usr/share/GeoIP/GeoIP.dat;
  
      # Get the header set by the load balancer
      real_ip_header   X-Forwarded-For;
      set_real_ip_from 0.0.0.0/0;
      real_ip_recursive on;
  
      server {
          listen       80;
          server_name  sub.domain.com;
  
          auth_basic "Restricted";
          auth_basic_user_file /etc/nginx/htpasswd/sub.domain.com.htpasswd;
  
          expires -1;
  
          access_log /var/log/nginx/sub.domain.com.access default;
          error_log  /var/log/nginx/sub.domain.com.error debug;
  
          location / {
              return 200 '{hello}';
          }
      }
  }
  </code></pre>
  
  <p>Interestingly, when I tried using an invalid file path as the value of auth_basic_user_file, the configtest still passes.  This should not be the case.</p>
  
  <p>Here's the Nginx and system info:</p>
  
  <pre><code>[root@ip nginx]# nginx -v
  nginx version: nginx/1.8.0
  
  [root@ip nginx]# uname -a
  Linux 4.1.7-15.23.amzn1.x86_64 #1 SMP Mon Sep 14 23:20:33 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
  </code></pre>
  
  <p>We are using the Nginx RPM available through yum.</p>