Haproxy
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_beg
但path_beg
會匹配嗎?
您還需要為一些非標準請求準備 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/