使用 monit 自动重启 nginx 代理

使用 monit 自动重启 nginx 代理

我尝试使用此配置在一台虚拟机中监控我的 nginx 代理

# cat /etc/monit/conf.d/nginx 
check process nginx with pidfile /run/nginx.pid
    start program = "/usr/sbin/service nginx start" with timeout 60 seconds
    stop program  = "/usr/sbin/service nginx stop"
    if failed host somedomain_here.org port 443 protocol http for 3 cycles then restart

但我只在 /var/log/monit.log 中收到这些错误

error    : 'nginx' failed protocol test [HTTP] at [somedomain_here.org]:443 [TCP/IP] -- Connection refused  

虽然域名有 https。代理本身似乎无法访问它代理到同一主机上其他虚拟机的站点。

如何监控nginx?

答案1

如果 nginx 仍在使用此配置运行,您可以检查 pid /etc/monit/conf.d/nginx

check process nginx with pidfile /var/run/nginx.pid
    start program = "/etc/init.d/nginx start"
    stop program = "/etc/init.d/nginx stop"

相关内容