• 技术文章 >运维 >Nginx

    先安装nginx再加健康模块么

    (*-*)浩(*-*)浩2019-06-18 11:05:15原创1157
    大家都知道,前段nginx做反向代理,如果后端服务器宕掉的话,nginx是不能把这台realserver提出upstream的,所以还会有请求转发到后端的这台realserver上面去,虽然nginx可以在localtion中启用proxy_next_upstream来解决返回给用户的错误页面。

    但这个还是会把请求转发给这台服务器的,然后再转发给别的服务器,这样就浪费了一次转发,这次借助与淘宝技术团队开发的nginx模块,nginx_upstream_check_module来检测后方realserver的健康状态,如果后端服务器不可用,则所有的请求不转发到这台服务器。

    安装配置

    文件列表信息

    [root@iZ233438q9fZ upload]# ll
    drwxr-xr-x 6 ftpuser ftp       4096 Aug 19 10:04 nginx_upstream_check_module
    drwxr-xr-x 8    1001 1001      4096 Jun 16  2015 nginx-1.9.2.tar.gz

    解压

    [root@iZ233438q9fZ upload]# tar -zxvf nginx-1.9.2.tar.gz
    [root@iZ233438q9fZ upload]# cd nginx-1.9.2

    nginx补丁安装

    [root@iZ233438q9fZ nginx-1.9.2]# patch -p0 < /var/ftp/upload/nginx_upstream_check_module/check_1.9.2+.patch
    patching file src/http/modules/ngx_http_upstream_hash_module.c
    patching file src/http/modules/ngx_http_upstream_ip_hash_module.c
    patching file src/http/modules/ngx_http_upstream_least_conn_module.c
    patching file src/http/ngx_http_upstream_round_robin.c
    patching file src/http/ngx_http_upstream_round_robin.h

    编译配置

    [root@iZ233438q9fZ nginx-1.9.2]# ./configure --add-module=/var/ftp/upload/nginx_upstream_check_module --prefix=/usr/local/server/nginx 
    [root@iZ233438q9fZ nginx-1.9.2]# make && make install

    nginx.conf健康检查配置样例

    nginx-6.png

    参数说明:

    - check_status:[html|csv|json],默认html

    - check_http_send:指定检测的http访问地址,默认/

    - type:[tcp|http|ssl_hello|mysql|ajp],默认tcp

    - interval:向后端发送的健康检查包的间隔,单位(毫秒)

    - fall(fall_count): 如果连续失败次数达到fall_count,服务器就被认为是down。

    - rise(rise_count): 如果连续成功次数达到rise_count,服务器就被认为是up。

    - timeout: 后端健康请求的超时时间。

    PS:如果一直显示失败,请检查项目根目录中是否有index.jsp或index.html

    更多Nginx相关技术文章,请访问Nginx使用教程栏目进行学习!

    以上就是先安装nginx再加健康模块么的详细内容,更多请关注php中文网其它相关文章!

    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    专题推荐:nginx
    上一篇:nginx与php怎么实现高并发 下一篇:nginx启动的时候提示端口被占用怎么解决办法

    相关文章推荐

    • nginx干什么的• nginx为什么比apache快• 怎么重启nginx服务• nginx收费吗

    全部评论我要评论

  • 取消发布评论发送
  • 1/1

    PHP中文网