# Rewriting Host and presenting certificate in Cloud-Env

**URL:** <https://discourse.haproxy.org/t/rewriting-host-and-presenting-certificate-in-cloud-env/3268>\
**Category:** Help!\
**Created:** [November 27, 2018, 8:08am UTC](https://discourse.haproxy.org/t/rewriting-host-and-presenting-certificate-in-cloud-env/3268 "2018-11-27T08:08:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![italianstallion](https://avatars.discourse-cdn.com/v4/letter/i/ed8c4c/32.png) [@italianstallion](https://discourse.haproxy.org/u/italianstallion)\
**Post date:** [November 27, 2018, 8:08am UTC](https://discourse.haproxy.org/t/rewriting-host-and-presenting-certificate-in-cloud-env/3268/1 "2018-11-27T08:08:54Z")

</div>

Hello all,

I have a small Cloud-Environment I deploy regularly with a Template containing two machines.  
Its a VPC with one TomcatApplicationServer in the back serving all the business/application-logic, data etc. and a haproxy machine in the front just redirecting all 80, 443 traffic to the backend.  
haproxy.cfg:

> frontend web\_unsafe \*:80  
> mode tcp  
> default\_backend web\_unsafe
> 
> backend web\_unsafe  
> mode tcp  
> server app1 10.0.2.11:80 check
> 
> frontend web\_unsafe \*:443  
> mode tcp  
> default\_backend web\_safe
> 
> backend web\_safe  
> mode tcp  
> server app1 10.0.2.11:443 check

The best thing about this config is that the IPs and and hostnames of all the Environments I deploy can be the same (Because changing it in all the configs of the App is very hard). During my Tests it was easy going because I changed my local host-file every time I deployed a Environment with a new External-IP.

But now I want to add A-Records in my Domain for every Environment I deploy and buy certificates.  
My idea is let the haproxy rewrite the Host and give the clients a certificate for the new name and don’t change the machine in the back. But I don’t get it done with the haproxy doc.  
Can somebody give me a hint how to change my config.

Regards  
Giuseppe

---

<div class="post-metadata">

**Author:** ![italianstallion](https://avatars.discourse-cdn.com/v4/letter/i/ed8c4c/32.png) [@italianstallion](https://discourse.haproxy.org/u/italianstallion)\
**Post date:** [November 27, 2018, 2:31pm UTC](https://discourse.haproxy.org/t/rewriting-host-and-presenting-certificate-in-cloud-env/3268/2 "2018-11-27T14:31:09Z")

</div>

I think rewriting is not the right way…it should be like proxypass or something like that.  
Just a redirect, not a rewriting of the URL.  
Right?
