Rewriting Host and presenting certificate in Cloud-Env

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

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?