下文给大家带来详细介绍反向代理负载均衡的处理过程的方法和步骤,希望能够给大家在实际运用中带来一定的帮助,负载均衡涉及的东西比较多,理论也不多,网上有很多书籍,今天我们就用亿速云在行业内累计的经验来做一个解答。

一、现象:

a.b.c.d - - [07/Jan/2017:04:21:45 +0000] "GET /cxf/sps-9cd4b47f-1c95-4f08-bf29-e536b9540a4a&pl6c378605000152&actionid=58706981d3 HTTP/1.1" 405 0 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"

405MethodNotAllowed:请求方法(GET、POST、HEAD、DELETE、PUT、TRACE等)对指定的资源不适用。

根本原因是自己用curl测试的时候默认使用的是get方法,我们需要用post方法:

curl -d "birthyear=1905&press=OK"https://gs-1c95-4f08-bf29-e536b9540a4a&playerid=6007409&cycleid=58706981d16c3786

a.b.c.d - - [07/Jan/2017:04:21:53 +0000] "GET /cxf/spin/rest/get6cc HTTP/1.1" 404 47 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"

为什么会出现404呢?就是因为请求没有获取到资源。这个由于自己的haproxy配置出错:

frontend main *:6443

#acl url_external path_beg -i /aeostervice

acl url_external path_beg -i /xf/sin/rest/

我们需要把/aeostervice改成/xf/sin/rest/

karaf简介:

http://wenku.baidu.com/link?url=y_SCAhXFtNgsjcoHrfCka36ygqeV-DUGlfZ-Q0RSRK5qRsRJt310zFEHjX0ullMCRJqRxWDD_p4bIFyxn4Af-pRlW2oWYELU5686SmFvflq

二、haproxy 超时机制

timeouthttprequest:在客户端建立连接但不请求数据时,关闭客户端连接

timeoutqueue:等待最大时长

timeoutconnect:定义haproxy将客户端请求转发至后端云服务器所等待的超时时长

timeoutclient:客户端非活动状态的超时时长

timeoutserver:客户端与服务器端建立连接后,等待服务器端的超时时长,

timeouthttp-keep-alive:定义保持连接的超时时长

timeoutcheck:健康状态监测时的超时时间,过短会误判,过长资源消耗

client_timeout是app连接haproxy的时间

server_timeout是haproxy连接后端的时间.

下面是我们自己的服务器配置:

defaults

mode http

log global

option httplog

option dontlognull

option http-server-close

option forwardfor except 127.0.0.0/8

option redispatch

retries 3

timeout http-request 10s注意:如果这里没有单位默认是毫秒

timeout queue 1m

timeout connect 10s

timeout client 1m

timeout server 1m

timeout http-keep-alive 10s

timeout check 10s

maxconn 3000

看了以上关于详细介绍反向代理负载均衡的处理过程的方法和步骤,如果大家还有什么地方需要了解的可以在亿速云行业资讯里查找自己感兴趣的或者找我们的专业技术工程师解答的,亿速云技术工程师在行业内拥有十几年的经验了。亿速云官网链接www.yisu.com