# 502 Bad gateway error after switching to SSL

**URL:** <https://meta.discourse.org/t/502-bad-gateway-error-after-switching-to-ssl/43477>\
**Category:** Self-hosting\
**Created:** [2016 年 4 月 29 日午後 11:04 UTC](https://meta.discourse.org/t/502-bad-gateway-error-after-switching-to-ssl/43477 "2016-04-29T23:04:26Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![glynhudson](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/glynhudson/32/120597_2.png) [@glynhudson](https://meta.discourse.org/u/glynhudson)\
**Post date:** [2016 年 5 月 1 日午後 6:19 UTC](https://meta.discourse.org/t/502-bad-gateway-error-after-switching-to-ssl/43477/4 "2016-05-01T18:19:11Z")

</div>

Solved it!

I think swapping the order of the templates so web.ssl template is listed before the web.socketed template and re-build:

```plaintext
templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
  - "templates/web.ssl.template.yml"
  - "templates/web.socketed.template.yml"

```

`/var/discourse/shared/standalone/nginx.https.sock` now exists and Nginx proxy can connect to it 🙂

---

_[View the full topic](https://meta.discourse.org/t/502-bad-gateway-error-after-switching-to-ssl/43477)._
