我有 1 個 haproxy 伺服器託管 website.com 和 1 個 nginx 伺服器託管 static.website.com 。我想要當 haproxy 收到 http 請求時http://website.com/static/image.jpg它會重寫:
主機 = website.com ==> 主機 = static.website.com
URI = /static/image.jpg ==> URI=/image.jpg
然後haproxy將http請求轉送到nginx伺服器,這裡
backend bk_nginx
mode http
# http-request replace-header if Host=website.com and URI=/static/image.jpg ==> rewrite them to Host=static.website.com and URI=/image.jpg
server node1 nginx-server:83 # forward http request to nginx server port 83 with Host=static.website.com and URI=/image.jpg
非常感謝您的幫忙。