# How to handle http to https redirect with load balancer and letsencrypt

**URL:** https://forums.suse.com/t/how-to-handle-http-to-https-redirect-with-load-balancer-and-letsencrypt/11074
**Category:** General
**Created:** [July 10, 2018, 3:42pm UTC](https://forums.suse.com/t/how-to-handle-http-to-https-redirect-with-load-balancer-and-letsencrypt/11074 "2018-07-10T15:42:58Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![palermomatt](https://avatars.discourse-cdn.com/v4/letter/p/8c91f0/32.png) [@palermomatt](https://forums.suse.com/u/palermomatt)
#### Post date: [July 10, 2018, 3:42pm UTC](https://forums.suse.com/t/how-to-handle-http-to-https-redirect-with-load-balancer-and-letsencrypt/11074/1 "2018-07-10T15:42:58Z")

</div>

I have a stack setup that uses the letsencrypt image from the catelog to do ssl termination from the built-in load balancer. I want to force non-ssl pages for my site to go to ssl, so I use this in the haproxy config:

```
frontend 80
redirect scheme https code 301 if !{ ssl_fc }

```

This works well. It redirects all my traffic to https, which is what I want. However, because of this, the letsencrypt service can’t be accessed on port 80 for certificate renewal. I have a service rule in place on the load balancer that sends the following path to letsencrypt on port 80:

`/.well-known/acme-challenge`

Since the haproxy config redirects to ssl, the verification process is never able to access the letsencrypt stack on port 80.

Does anyone have any advice on how to handle this? I’d like to keep forwarding all non-ssl traffic to ssl on my site, but allow an exception for the `/.well-known/acme-challenge` path to go through on port 80 to renew the certificate.

---

<div class="post-metadata">

### Author: ![mdaly001](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@mdaly001](https://forums.suse.com/u/mdaly001)
#### Post date: [September 3, 2018, 4:30am UTC](https://forums.suse.com/t/how-to-handle-http-to-https-redirect-with-load-balancer-and-letsencrypt/11074/2 "2018-09-03T04:30:24Z")

</div>

> [@palermomatt](#):
>
> frontend 80 redirect scheme https code 301 if !{ ssl\_fc }

hey did you ever figure this out? running into the same thing

---

<div class="post-metadata">

### Author: ![palermomatt](https://avatars.discourse-cdn.com/v4/letter/p/8c91f0/32.png) [@palermomatt](https://forums.suse.com/u/palermomatt)
#### Post date: [September 6, 2018, 2:32pm UTC](https://forums.suse.com/t/how-to-handle-http-to-https-redirect-with-load-balancer-and-letsencrypt/11074/3 "2018-09-06T14:32:29Z")

</div>

No, I haven’t solved this yet. So far, I’ve just been manually turning off the SSL redirect to renew the cert, then I turn it back on.

If anyone else has suggestions for this, please let me know.

---

<div class="post-metadata">

### Author: ![mkuendig](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mkuendig](https://forums.suse.com/u/mkuendig)
#### Post date: [September 7, 2018, 2:22am UTC](https://forums.suse.com/t/how-to-handle-http-to-https-redirect-with-load-balancer-and-letsencrypt/11074/4 "2018-09-07T02:22:07Z")

</div>

I do it like this:

```
acl letsencrypt path_beg /.well-known/acme-challenge/
redirect scheme https code 301 if !letsencrypt !{ ssl_fc }
```
