Proxy

使用 monit 自動重啟 nginx 代理

  • July 26, 2017

我嘗試使用此配置在一個 VM 中監控我的 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?

如果 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"

引用自:https://unix.stackexchange.com/questions/381884