标签:信息 vat ISE 报文 oca 服务器 响应报文 rdf curl
HAProxy修改报文首部HAProxy可以对请求或响应报文的首部进行修改,从而对用户增加或隐藏部分首部信息
# 在请求报文尾部添加指定的报文
reqadd <string> [{if|unless} <cond>]
# 在响应报文尾部添加指定的报文
rspadd <string> [{if|unless} <cond>]
示例:
在响应报文的尾部添加经过haproxy服务器
listen web
bind 172.20.27.20:80
mode http #修改报文首部的前提是工作在http模式下
rspadd x-via:\ haproxy #响应首部中要添加的内容
cookie SERVER-COOKIE insert indirect nocache
option forwardfor
server web1 192.168.27.21:80 cookie web1 check inter 3000 fall 3 rise 5
server web2 192.168.27.22:80 cookie web2 check inter 3000 fall 3 rise 5
测试
访问 172.20.27.20
[root@localhost ~]# curl -I 172.20.27.20
HTTP/1.1 200 OK
Server: nginx/1.17.0
Date: Wed, 05 Jun 2019 12:20:19 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 04 Jun 2019 07:35:24 GMT
ETag: "5cf61f3c-264"
Accept-Ranges: bytes
x-via: haproxy #响应报文投不中出现所添加的内容
Set-Cookie: SERVER-COOKIE=web2; path=/
Cache-control: private
# 从请求报文中删除匹配正则表达式的首部
reqdel <search> [{if|unless} <cond>]
reqidel <search> [{if|unless} <cond>]
# 从响应报文中删除匹配正则表达式的首部
rspdel <search> [{if|unless} <cond>]
rspidel <search> [{if|unless} <cond>]
示例:
删除响应头信息
未删除前
[root@localhost ~]# curl -I 172.20.27.20
HTTP/1.1 200 OK
Server: nginx/1.17.0 #显示了后端server的信息
Date: Wed, 05 Jun 2019 12:20:19 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 04 Jun 2019 07:35:24 GMT
ETag: "5cf61f3c-264"
Accept-Ranges: bytes
x-via: haproxy
Set-Cookie: SERVER-COOKIE=web2; path=/
Cache-control: private
修改配置文件
listen web
bind 172.20.27.20:80
mode http
rspadd x-via:\ haproxy
rspdel Server:.* #对要删除的头部进行正则表达式匹配
cookie SERVER-COOKIE insert indirect nocache
option forwardfor
server web1 192.168.27.21:80 cookie web1 check inter 3000 fall 3 rise 5
server web2 192.168.27.22:80 cookie web2 check inter 3000 fall 3 rise 5
测试
[root@localhost ~]# curl -I 172.20.27.20
HTTP/1.1 200 OK
Date: Wed, 05 Jun 2019 12:38:56 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 04 Jun 2019 07:35:24 GMT
ETag: "5cf61f3c-264"
Accept-Ranges: bytes
x-via: haproxy
Set-Cookie: SERVER-COOKIE=web2; path=/
Cache-control: private
标签:信息 vat ISE 报文 oca 服务器 响应报文 rdf curl
原文地址:https://blog.51cto.com/11886307/2406605