下载所需软
wget http://nginx.org/download/nginx-1.16.1.tar.gz
git clone https://github.com/yaoweibin/nginx_upstream_check_module.git
yum -y install gcc-c++ pcre-devel openssl openssl-devel libxml2 libxml2-dev libxslt-devel autoconf automake gd gd-devel perl-devel perl-ExtUtils-Embed libuuid-devel libblkid-devel libudev-devel fuse-devel libedit-devel libatomic_ops-devel
开始编辑增加 nginx_upstream_check_module
tar zxf nginx-1.16.1.tar.gz
cd nginx-1.16.1
patch -p1 < /usr/local/nginx/nginx_upstream_check_module/check_1.16.1+.patch (根据nginx版本打补丁)
开始编译
./configure --prefix=/usr/local/nginx --add-module=/usr/local/nginx/nginx_upstream_check_module --error-log-path=/usr/local/nginx/logs/error.log --http-log-path=/usr/local/nginx/logs/access.log --pid-path=/usr/local/nginx/run/nginx.pid --lock-path=/usr/local/nginx/nginx.lock --user=nginx --group=nginx --with-select_module --with-poll_module --with-threads --with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_stub_status_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-stream=dynamic --with-stream_ssl_module --with-stream_realip_module --with-stream_ssl_preread_module --with-pcre --with-libatomic --http-client-body-temp-path=/usr/local/nginx/client_body/ --http-proxy-temp-path=/usr/local/nginx/proxy/ --http-fastcgi-temp-path=/usr/local/nginx/fastcgi/ --http-uwsgi-temp-path=/usr/local/nginx/uwsgi --http-scgi-temp-path=/usr/local/nginx/scgi
#无报错后make && make install
upstream bi {
server 11.11.11.11:80 weight=10 max_fails=2 fail_timeout=5s;
server 12.12.12.12:80 weight=10 max_fails=2 fail_timeout=5s;
check interval=3000 rise=2 fall=3 timeout=1000 type=http default_down=false;
check_http_send "GET /api/admin/healthcheck HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx http_3xx;
}
server{
listen 80;
server_name bi.xx.comt;
access_log /usr/local/nginx/logs/bi_xxx_access.log main;
location / {
proxy_pass http://bi;
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_read_timeout 600s;
}
}
网友评论