haproxy 中 url_beg 和 path_beg 的区别

haproxy 中 url_beg 和 path_beg 的区别

Haproxy doc 更喜欢使用 path_beg 而不是 url_beg 来匹配 url 中的路径。

按照https://cbonte.github.io/haproxy-dconv/configuration-1.5.html#url

With ACLs, using "path" is preferred over using "url", because clients may send a full URL as is normally done with proxies.

似乎在上述情况下 url_beg 不起作用,我不明白它是什么意思。我可以让 curl 按原样发送完整的 url,这样不会被匹配,url_begpath_beg会匹配它吗?

答案1

您还需要为 haproxy 准备一些非标准请求。看看这个奇怪的GET

$ echo -ne "GET http://google.com/books/ HTTP/1.1\r\nHost: google.com\r\n\r\n" | nc -v google.com 80
Connection to google.com 80 port [tcp/http] succeeded!
HTTP/1.1 301 Moved Permanently
Location: http://books.google.com/books/
...

为了进行比较,标准方法:

$ echo -ne "GET /books/ HTTP/1.1\r\nHost: google.com\r\n\r\n" | nc -v google.com 80
Connection to google.com 80 port [tcp/http] succeeded!
HTTP/1.1 301 Moved Permanently
Location: http://books.google.com/books/
...

以及如何使用以下命令生成同样奇怪的 GET curl

$ curl -v --request-target http://google.com/books/ http://google.com/books/
*   Trying 172.217.16.14...
* TCP_NODELAY set
* Connected to google.com (172.217.16.14) port 80 (#0)
> GET http://google.com/books/ HTTP/1.1
> Host: google.com
> User-Agent: curl/7.55.1
> Accept: */*
> 
< HTTP/1.1 301 Moved Permanently
< Location: http://books.google.com/books/

相关内容