我有一个流量非常低的 Nginx 机器,用作外部服务的反向代理。机器上安装了 Monit,nginx
如果崩溃了,它会重新启动。不用说,nginx
这台机器每天至少会停止一次,monit
必须重新启动它。
这是我的monit
配置:
check process nginx with pidfile /var/run/nginx.pid
start program = "/etc/init.d/nginx start"
stop program = "/etc/init.d/nginx stop"
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 25 cycles then restart
if totalmem > 400.0 MB for 5 cycles then restart
if children > 250 then restart
if loadavg(5min) greater than 10 for 8 cycles then stop
if failed host 127.0.0.1 port 80 protocol http
then restart
if 3 restarts within 5 cycles then timeout
这是我的网站配置nginx
:
server {
listen 80;
server_name somedomainname.com;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location / {
proxy_pass https://somedomainname.com;
proxy_redirect off;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
}
答案1
您的问题可能是由于monit
未发送“Host:”标头字段造成的。请尝试通过设置一个未使用代理的监控器来location
解决这个问题:monit
location = /test_target.html {
root /var/www/public;
}
(我通过搜索找到了这个答案nginx 监控 499。这是第一个结果。)