# Problem with site who redirect to HTTPS

**URL:** <https://discourse.haproxy.org/t/problem-with-site-who-redirect-to-https/9311>\
**Category:** Help!\
**Created:** [December 11, 2023, 9:10am UTC](https://discourse.haproxy.org/t/problem-with-site-who-redirect-to-https/9311 "2023-12-11T09:10:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ronenu](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@ronenu](https://discourse.haproxy.org/u/ronenu)\
**Post date:** [December 11, 2023, 9:10am UTC](https://discourse.haproxy.org/t/problem-with-site-who-redirect-to-https/9311/1 "2023-12-11T09:10:27Z")

</div>

Hi All 🙂  
i am trying to configure HAproxy for SSL Termination  
the Backend is an Umbraco IIS website who redirect all traffic to HTTPS

when i Browsing through the HAproxy i receive " ERR\_TOO\_MANY\_REDIRECTS "  
there is a Loop redirecting to HTTPS

if the backend is a "Regular site " who does not have a built in HTTPS redirection  
then it is working fine ( i can browse both HTTP and HTTPS )

how can i solve this ?

here is my backend config

backend backend\_contoso.com  
balance leastconn  
option httpchk HEAD / HTTP/1.1\r\nHost:\ contoso.com  
option forwardfor  
option redispatch  
option log-health-checks  
default-server inter 5s fall 3 rise 5  
http-check expect rstatus (2|3)[0-9][0-9]  
http-request set-header X-Forwarded-Port %[dst\_port]  
cookie SERVERUSED indirect nocache insert  
http-request redirect scheme https unless { ssl\_fc }  
server iis2 192.168.1.85:80 maxconn 10000 check cookie iis1

Thank you.

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [December 11, 2023, 10:18am UTC](https://discourse.haproxy.org/t/problem-with-site-who-redirect-to-https/9311/2 "2023-12-11T10:18:31Z")

</div>

> [@ronenu](#):
>
> if the backend is a "Regular site " who does not have a built in HTTPS redirection  
> then it is working fine ( i can browse both HTTP and HTTPS )
> 
> how can i solve this ?

Disable redirection on the backend or figure out a way to tell your backend when the request is already done via HTTPS.

X-Forwarded-Port or X-Forwarded-Proto are ways to do that. But your backend needs to support it.

---

<div class="post-metadata">

**Author:** ![ronenu](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@ronenu](https://discourse.haproxy.org/u/ronenu)\
**Post date:** [December 11, 2023, 12:13pm UTC](https://discourse.haproxy.org/t/problem-with-site-who-redirect-to-https/9311/3 "2023-12-11T12:13:54Z")

</div>

HI , Can you show me an example how to do that ?

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [December 11, 2023, 12:17pm UTC](https://discourse.haproxy.org/t/problem-with-site-who-redirect-to-https/9311/4 "2023-12-11T12:17:22Z")

</div>

> [@ronenu](#):
>
> http-request set-header X-Forwarded-Port %[dst\_port]

You are already doing:

```
http-request set-header X-Forwarded-Port %[dst_port]

```

You can add:

```
http-request set-header X-Forwarded-Proto %[ssl_fc,iif(https,http)]

```

Again your backend needs to support it.

---

<div class="post-metadata">

**Author:** ![ronenu](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@ronenu](https://discourse.haproxy.org/u/ronenu)\
**Post date:** [December 11, 2023, 12:24pm UTC](https://discourse.haproxy.org/t/problem-with-site-who-redirect-to-https/9311/5 "2023-12-11T12:24:56Z")

</div>

so i added this line  
http-request set-header X-Forwarded-Proto %[ssl\_fc,iif(https,http)]

but the same thing i am still getting “ERR\_TOO\_MANY\_REDIRECTS”

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [December 11, 2023, 12:41pm UTC](https://discourse.haproxy.org/t/problem-with-site-who-redirect-to-https/9311/6 "2023-12-11T12:41:36Z")

</div>

Which is why I said your backend needs to actually support it, or you need to disable the redirect at the backend.

---

<div class="post-metadata">

**Author:** ![ronenu](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@ronenu](https://discourse.haproxy.org/u/ronenu)\
**Post date:** [December 11, 2023, 12:45pm UTC](https://discourse.haproxy.org/t/problem-with-site-who-redirect-to-https/9311/7 "2023-12-11T12:45:32Z")

</div>

the backend is Windows 2016 IIS server  
does it support it ?

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [December 11, 2023, 12:58pm UTC](https://discourse.haproxy.org/t/problem-with-site-who-redirect-to-https/9311/8 "2023-12-11T12:58:22Z")

</div>

The operating systems and webserver is irrelevant.

The backend application is relevant.
