nginx添加nginx_upstream_check_module
#cd nginx source folder cd /usr/local/nginx/nginx-1.18.0 wget https://github.com/yaoweibin/nginx_upstream_check_module/archive/refs/heads/master.zip unzip master.zip mkdir nginx_upstream_check_module mv nginx_upstream_check_module/* ./nginx_upstream_check_module/ ./configure --add-module=./nginx_upstream_check_module #if need ssl #./configure --add-module=./nginx_upstream_check_module --with-http_ssl_module #backup old nginx file mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old #replace new nginx file mv /usr/local/nginx/nginx-1.18.0/objs/nginx /usr/local/nginx/sbin/nginx #check nginx modules /usr/local/nginx/sbin/nginx -t #reload nginx /usr/local/nginx/sbin/nginx -s reload
nginx_upstream_check_module相关配置:
#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; upstream guccimpapi{ server localhost:8000; server localhost:9000; # Enable health checks check interval=3000 rise=2 fall=2 timeout=2000; # HTTP settings for health checks check_http_send "HEAD /api/health HTTP/1.0\r\n\r\n"; check_http_expect_alive http_2xx http_3xx; } server { listen 80; listen 443 ssl; server_name xxxx.com; root /usr/local/nginx/html/wecom-crm; location / { try_files $uri $uri/ /index.html; } ssl_certificate /usr/local/nginx/ssl/xxx.pem; ssl_certificate_key /usr/local/nginx/ssl/xxx.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; # Load configuration files for the default server block. #include /etc/nginx/default.d/*.conf; error_page 404 /404.html; location = /404.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } location /mp/ { proxy_pass http://guccimpapi; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 15s; proxy_send_timeout 15s; proxy_read_timeout 15s; } #proxy-end==================================== } }