0
votes

I am using haproxy in front of my web-server for ssl termination.

I am forwarding request on port 81 if request is https and 80 if request is normal http-

backend b1_http
    mode http
    server bkend_server


backend b1_https
    mode http
    server bkend_server:81

Problem is, when haproxy sends request to back-end, it sends HTTP_HOST header as request.domain.com:81.

Is it possible in haproxy that I can send https request to back-end at specific port without appending the port in HTTP_HOST request header?

1

1 Answers

1
votes

There are two issues, here.

First, there is no HTTP_HOST header. The header is Host:. It sounds like HTTP_HOST is something being generated internally by your web server or framework.

Second, HAProxy doesn't modify the Host: header just because your back-end is listening on a port other than 80. It doesn't actually modify the Host: header at all, unless explicit configured to, using a mechanism like reqirep ^Host: ... or http-request set-header host ....

You can confirm this with a packet capture. You should find that whatever HTTP_HOST is, the value is necessarily being generated internally on the back-end system itself, because it's not coming from HAProxy.