我的haproxy.cfg就是这个
frontend go 127.0.0.1:8081
timeout client 86400000
acl ddos_log path_beg /ddoslogger/
use_backend ddos_backend if ddos_log
use_backend normal_backend if !ddos_log
backend ddos_backend
mode http
option httplog
balance uri
# Will add more servers if this works
server go11 localhost:8083 check
server go11 localhost:8083 backup
backend normal_backend
mode http
option httplog
option allbackups
default-server weight 50 slowstart 30s inter 3s fastinter 2s downinter 5s
server go10 localhost:8082 check
server go10 localhost:8082 backup
我打算做的基本上是针对“/ ddoslogger /”的所有查询,我将使用balance uri方法来选择服务器,而其他人使用不同的负载平衡方法。两者都与同一组服务器通信(我已经删除了其他服务器以进行调试)
当我在调试模式下向haproxy发出请求时,我得到了什么
00000000:go.accept(0004)=0006 from [127.0.0.1:58054]
00000000:normal_backend.clireq[0006:ffff]: POST /ddoslogger/a01324jlkas HTTP/1.1
00000000:normal_backend.clihdr[0006:ffff]: Host: localhost:8081
00000000:normal_backend.clihdr[0006:ffff]: Connection: keep-alive
00000000:normal_backend.clihdr[0006:ffff]: Content-Length: 204
00000000:normal_backend.clihdr[0006:ffff]: Cache-Control: no-cache
00000000:normal_backend.clihdr[0006:ffff]: Origin: chrome-extension://fdmmgilgnpjigdojojpjoooidkmcomcm
00000000:normal_backend.clihdr[0006:ffff]: User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.65 Safari/537.36
00000000:normal_backend.clihdr[0006:ffff]: Content-Type: application/x-www-form-urlencoded
00000000:normal_backend.clihdr[0006:ffff]: Accept: */*
00000000:normal_backend.clihdr[0006:ffff]: Accept-Encoding: gzip,deflate,sdch
00000000:normal_backend.clihdr[0006:ffff]: Accept-Language: en-US,en;q=0.8
00000000:normal_backend.clihdr[0006:ffff]: Cookie: <truncated>
00000000:normal_backend.srvrep[0006:0007]: HTTP/1.1 200 OK
00000000:normal_backend.srvhdr[0006:0007]: Content-Type: text/plain; charset=utf-8
00000000:normal_backend.srvhdr[0006:0007]: Content-Length: 0
00000000:normal_backend.srvhdr[0006:0007]: Date: Thu, 19 Sep 2013 03:55:19 GMT
对我做错了什么建议?
答案 0 :(得分:2)
通过移动
解决了这个问题mode http
option httplog
到前端服务,现在看起来像这样:
frontend go 127.0.0.1:8081
timeout client 86400000
mode http
option httplog
acl ddos_log path_beg /ddoslogger/
use_backend ddos_backend if ddos_log
use_backend normal_backend if !ddos_log
.
.
.
如果其他人正在努力解决这个问题!