1

I was trying to configure nginx so that http://example.com/monit will access http://127.0.0.1:2812, which is the url monit is listening.

Two authentication was set, via nginx(nginx.conf file) and monit(monitrc file).

Now, accessing http://example.com/monit/, should popup two input forms, but after entering the second one(via monit), the nginx one pops up again. Can anyone point out what is wrong?

(note: solving this problem is easy - turn off one basic authentication)

I tested with debian jessie. sorry if it won't reproduce


this is my /usr/local/nginx/conf/nginx.conf (installed from source)

server{
    ...
    auth_basic "restricted"
    auth_basic_user_file /home/user/.htpasswd;
    location /monit/ {
        rewrite ^/monit/(.*) /$1 break;
        proxy_pass  http://127.0.0.1:2812;
    }
}

This configuration requires the user to enter the user/password to access any file in this server directive. if the uri starts with /monit/, it enteres the location directive and it is passed to 127.0.0.1:2812. simple.

Then in /etc/monitrc, I set a basic authentication.

set httpd port 2812 and
    allow 127.0.0.1      # allow access only from localhost
    allow admin:monit    # user:password

this makes monit accessible from localhost only.

user261134
  • 19
  • 2

0 Answers0