nginx和monit web界面 - 如何在domain.com/monit和domain.com上进行监控

3 nginx monit

我在我的ec2实例上使用monit而且我是nginx的新手.下面是我的nginx配置文件:

server {
  listen 80;
  server_name 127.0.0.1;
  location / {
    proxy_pass 127.0.0.1:2812;
    proxy_set_header Host $host;
  }
}
Run Code Online (Sandbox Code Playgroud)

所以..如果我去domain.com,我看到monit.如何修改上面的代码,我可以在domain.com/monit上看到monit?

谢谢

Ser*_*kov 10

请试试这个:

server {
  listen 80;
  server_name 127.0.0.1;

  location /monit/ {
    proxy_pass http://127.0.0.1:2812;
    proxy_set_header Host $host;
  }

}
Run Code Online (Sandbox Code Playgroud)

在这里阅读更多关于指令位置如何在nginx中工作的内容


Dmi*_*lov 5

Monit 的wiki 中有一篇文章如何使用 Nginx 配置它。

这是我的/etc/nginx/conf.d/monit.conf

server {
    listen   80;
    server_name  my.server.name;

    location /monit/ {
            allow 127.0.0.1;
            allow 192.0.0.0/8;
            deny all;

            proxy_pass http://127.0.0.1:2812;
            proxy_set_header Host $host;
            rewrite ^/monit/(.*) /$1 break;
            proxy_ignore_client_abort on;
    }
}
Run Code Online (Sandbox Code Playgroud)