# Force Redirect HTTP to HTTPS

**URL:** <https://meta.discourse.org/t/force-redirect-http-to-https/57393>\
**Category:** Product Support\
**Created:** [February 14, 2017, 10:17pm UTC](https://meta.discourse.org/t/force-redirect-http-to-https/57393 "2017-02-14T22:17:44Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![jose-zama](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jose-zama/32/131701_2.png) [@jose-zama](https://meta.discourse.org/u/jose-zama)\
**Post date:** [January 4, 2019, 6:16pm UTC](https://meta.discourse.org/t/force-redirect-http-to-https/57393/9 "2019-01-04T18:16:22Z")

</div>

For people who use AWS Classic Load Balancer still trying to solve this.

You should read this page: [Use Elastic Load Balancing to redirect HTTP traffic to HTTPS | AWS re:Post](https://aws.amazon.com/premiumsupport/knowledge-center/redirect-http-https-elb/)

Basically, Ngnix should redirect to https if `X-Forwarded-Proto: http` . This header is set by the load balancer. Thus the communication between web server and load balancer is always http. That means that Ngnix serves only http and the load balancer through https.

So, what I did, was to add the following to my container configuration (web.yml):

```plaintext
run:
    - replace:
       filename: "/etc/nginx/conf.d/discourse.conf"
       from: /server.+{/
       to: |
         server {
           if ($http_x_forwarded_proto = 'http'){
            return 301 https://$host$request_uri;
           }

```

---

_[View the full topic](https://meta.discourse.org/t/force-redirect-http-to-https/57393)._
