分类

链接

2024 年 7 月
1234567
891011121314
15161718192021
22232425262728
293031  

近期文章

热门标签

新人福利,免费薅羊毛

现在位置:    首页 > 微服务, 系统架构 > 正文
共享办公室出租
nginx主动健康检查负载均衡模块
微服务, 系统架构 暂无评论 阅读(48)

下载模块,放到源代码根目录:

nginx_upstream_check_module

 

重新安装:

./configure --add-module=./nginx_upstream_check_module --with-http_ssl_module --with-http_v2_module --with-stream --with-http_gzip_static_module

 

#默认安装到/usr/local/nginx下面

make

sudo make install

 

#查看版本(可看到所有编译进去的模块)

/usr/local/bin/nginx -V

#安装到全局(看自己的目录)

cp /usr/sbin/nginx /usr/local/bin/nginx.bak

cp ./objs/nginx /usr/local/bin/nginx

 

使用方法:

#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;
 
    #access_log  logs/access.log  main;
    error_log  logs/error.log;

    sendfile        on;
    
    client_max_body_size 100m;
    client_header_timeout 300s;
    client_body_timeout 300s;

    gzip  on;
    gzip_static on; 


    upstream crmapi{

        server 127.0.0.1:8002;
        server 127.0.0.1:9002;

        # Enable health checks
        check interval=3000 rise=2 fall=2 timeout=2000 type=http;

        # HTTP settings for health checks
        check_http_send "GET /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  _;

        root         /usr/local/nginx/html;

        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;
     
        location /crm/ {
            proxy_pass http://crmapi/;
            proxy_set_header  Host             $host;
            proxy_set_header  X-Real-IP        $remote_addr;
            proxy_set_header  X-Forwarded-For  $remote_addr;
            proxy_connect_timeout 300s;
            proxy_send_timeout 300s;
            proxy_read_timeout 300s;
        } 
        #proxy-end====================================

    }

}

 

 

============ 欢迎各位老板打赏~ ===========

本文版权归Bruce's Blog所有,转载引用请完整注明以下信息:
本文作者:Bruce
本文地址:nginx主动健康检查负载均衡模块 | Bruce's Blog

发表评论

留言无头像?