首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Nginx M/Monit密码保护

Nginx M/Monit密码保护
EN

Stack Overflow用户
提问于 2016-02-06 15:26:46
回答 1查看 338关注 0票数 0

我试图保护对M/Monit网络接口的访问:

盒:

ubuntu 14.04

nginx 1.8.1

mmonit-3.5.1

我在/etc/nginx/sites-available下创建了一个mmonit配置文件

代码语言:javascript
复制
server {
        listen 8080;
        root /var/www/html;
        location / {
                auth_basic "Restricted Content";
                auth_basic_user_file /etc/nginx/.htpasswd;
        }

        location ~ /\.ht {
                deny all;
        }

}

它不显示身份验证对话框。我跟踪了serverfault-Nginx Password Protect Entire Port Number 8081,但似乎我做错了什么.我对nginx并不熟悉。

有人知道怎么做吗?它应该在同一个default服务器配置文件中吗?干杯

EN

回答 1

Stack Overflow用户

发布于 2016-02-11 11:58:16

所以我想出来了..。

(这是在默认服务器配置下)

代码语言:javascript
复制
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/

给予:mmonit -> /path/to/your/mmonit/folder/

现在将浏览器指向:http://yourServerIp/mmonit/

您将拥有“身份验证所需”对话框!

A username and password are being requested by http://yourServerIp. The site says: "Restricted Content"

**我确实建议把这个链接称为其他的东西,然后是mmonit....to你的选择。

任何途径你的访问现在都是双重保护!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35242731

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档