# DiscourseConnect generates HTTP redirects even with force\_https on

**URL:** <https://meta.discourse.org/t/discourseconnect-generates-http-redirects-even-with-force-https-on/309338>\
**Category:** Self-hosting\
**Tags:** discourseconnect\
**Created:** [May 24, 2024, 8:52pm UTC](https://meta.discourse.org/t/discourseconnect-generates-http-redirects-even-with-force-https-on/309338 "2024-05-24T20:52:28Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![matiasgarciaisaia](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/matiasgarciaisaia/32/509263_2.png) [@matiasgarciaisaia](https://meta.discourse.org/u/matiasgarciaisaia)\
**Post date:** [May 24, 2024, 8:52pm UTC](https://meta.discourse.org/t/discourseconnect-generates-http-redirects-even-with-force-https-on/309338/1 "2024-05-24T20:52:28Z")

</div>

I’m running Discourse behind Traefik in a custom setup - giving Discourse its own VM is not an option here.

My Discourse doesn’t have SSL/Let’sEncrypt templates enabled, since Traefik won’t let plain HTTP requests reach the container - it’s set to redirect HTTP requests to HTTPs.

I’m having issues setting up [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true), because, since the `Traefik -> nginx[Discourse]` request is sent over plain-text HTTP (because nginx doesn’t have SSL set up), the rule in `/etc/nginx/conf.d/discourse.conf` that tries `to preserve the proto, must be in http context` makes Discourse (the Rails app) to receive a plain-text HTTP request, thus returning a plain-text HTTP redirect to `/session/sso` - even if I have `force_https` enabled.

I think that’s the bug: regardless of my setup, with `force_https` enabled, Discourse should always generate HTTPs URLs - which it’s not doing.

I think the offending code is `application_controller#redirect_to_login`, but I haven’t dug that much into Discourse source code to be sure.

**Is this solvable in the code itself?**

As a workaround, I’m trying to add a rule patching the nginx’s `discourse.conf` to remove that rule.

---

_[View the full topic](https://meta.discourse.org/t/discourseconnect-generates-http-redirects-even-with-force-https-on/309338)._
