# Adding port to header host

**URL:** <https://discourse.haproxy.org/t/adding-port-to-header-host/9236>\
**Category:** Help!\
**Created:** [November 16, 2023, 7:51am UTC](https://discourse.haproxy.org/t/adding-port-to-header-host/9236 "2023-11-16T07:51:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![marypoppins](https://avatars.discourse-cdn.com/v4/letter/m/a88e57/32.png) [@marypoppins](https://discourse.haproxy.org/u/marypoppins)\
**Post date:** [November 16, 2023, 7:51am UTC](https://discourse.haproxy.org/t/adding-port-to-header-host/9236/1 "2023-11-16T07:51:15Z")

</div>

Dear All,  
I would like to add port to the incoming Host request header if that not included it.  
I think I have managed to solve the problem in the way mentioned below. I just would like to ask for the experienced veterans is there any problem with this solution or is there any easier one?

acl port\_exists req.fhdr(Host) -m sub “:”  
http-request set-var(req.h\_host) req.fhdr(Host),lower  
http-request set-header Host %[var(req.h\_host)]:%[dst\_port] if !port\_exists

Thank you very much!
