Monit Web Service(HTTPD)不可用

时间:2016-02-10 12:53:50

标签: chef monitoring chef-solo monit

我尝试使用自己的主厨和monit cookbook在我的服务器上配置monit。当我访问端口2812回复说this webpage is not available时。这仅在通过Web浏览器远程访问时。我在本地卷曲时得到了预期的内容。

monit cookbook

include_recipe 'monit'

cookbook_file '/etc/monit/conf.d/puma.conf' do
  source 'monit-puma'
  owner 'deploy'
  group 'deploy'
  mode '0755'
  action :create
end

cookbook_file '/etc/monit/conf.d/nginx.conf' do
  source 'monit-nginx'
  owner 'deploy'
  group 'deploy'
  mode '0755'
  action :create
end

execute 'sudo monit reload'

/etc/monit/conf.d/compat.conf

set httpd port 2812
  use address 127.0.0.1
  allow admin:mybestpassword

默认属性

default['monit']['port'] = '2812'
default['monit']['username'] = 'admin'
default['monit']['password'] = '...'
default['monit']['address'] = '0.0.0.0'
default['monit']['allow'] = ['0.0.0.0']

poise-monit UPDATE

monit 'monit' do
  daemon_interval 30
  event_slots 1000
  httpd_port 2812
  httpd_username 'admin'
  httpd_password 'Password1'
  group 'deploy'
end

poise-monit食谱

monit 'monit' do
  daemon_interval 30
  event_slots 1000
  httpd_port 2812
  httpd_username 'admin'
  httpd_password 'Password1'
  group 'deploy'
end


monit_config 'nginx' do
  source 'monit_nginx.conf.erb'
end


monit_config 'puma' do
  source 'monit-puma.conf.erb'
end

poise-monit生成/ etc / monit / monitrc

# Generated by Chef for monit[monit]

SET PIDFILE /var/run/monit_real.pid

SET LOGFILE /var/log/monit.log

SET IDFILE /var/lib/monit/id
SET STATEFILE /var/lib/monit/state
SET EVENTQUEUE BASEDIR /var/lib/monit/events SLOTS 1000

SET HTTPD PORT 2812
  ALLOW admin:Password1

INCLUDE /etc/monit/conf.d/*

2 个答案:

答案 0 :(得分:1)

set httpd port 2812
  use address 127.0.0.1
  allow admin:mybestpassword

你只是在localhost(127.0.0.1)上听,所以很明显不会在远程通话中回答。

阅读monit cookbook自述文件(也是你链接的那个),有一个控制它的属性:

node['monit']['address'] – Local address to bind to for Monit's HTTPD interface. (default: nil)

在cookbook属性文件中设置default['monit']['address'] = '0.0.0.0',将其配置为侦听所有可用接口。

一个ACL允许每个文档中的注释,所以结局属性文件应该包括(未经测试):

default['monit']['address'] = '0.0.0.0'
default['monit']['allow'] = ['0.0.0.0']

答案 1 :(得分:1)

如README中所述,您需要为要使用的节点属性设置密码或allow设置。否则他们会因安全而被忽略。您可以查看poise-monit文档,了解有关配置Web UI的更多详细说明。