0

I am trying to secure the login URL of my website (Ajenti control panel) with auth_basic authentication. I access the site like this: https://myajentiinstallation.com:8787

In the file /etc/nginx.custom.d/codes.conf, I have this code:

server {
        listen 8787 ssl;
        ssl_certificate /etc/ssl/other/cert.crt;
        ssl_certificate_key  /etc/ssl/other/key.key;
        location / {
                auth_basic "Admin Login";
                auth_basic_user_file /etc/other/htpass;
        }
}

However, when I go to https://myajentiinstallation.com:8787, I am taken to Nginx's default page!

How can I secure my Ajenti login page with auth_basic authentication?

Thanks!

Pamela
  • 187
  • 2
  • 13
  • 1
    Either the config you posted is incomplete, or you are missing some kind of directive telling nginx what to do with incoming requests - for example `root` pointing to a static document root, or `proxy_pass` passing requests to a backend handler. It might also be that you're missing a `server_name` directive setting the host name, so your requests are falling back to the default vhost. – shevron Jul 01 '15 at 19:25
  • 1
    Have you tested config and restarted nginx? – Alexey Ten Jul 02 '15 at 05:03
  • @AlexeyTen, yes, when I run `nginx t`, everything is OK. I have restarted Nginx and have even restarted the entire server, but it is still giving the same problem. – Pamela Jul 02 '15 at 13:53
  • 1
    Are you sure your `myajentiinstallation.com` points to right server? – Alexey Ten Jul 02 '15 at 14:42
  • @AlexeyTen, yes. Without the above directives, I am able to access the website just fine. It is just when I try to secure it with auth_basic with the above directives, that it brings me to Nginx's default page. – Pamela Jul 03 '15 at 19:57

0 Answers0