# 502 Gateway Error: Discourse Installation with SSL form Cloudflare

**URL:** https://meta.discourse.org/t/502-gateway-error-discourse-installation-with-ssl-form-cloudflare/157986
**Category:** Self-hosting
**Created:** [16 juli 2020 om 22:15 UTC](https://meta.discourse.org/t/502-gateway-error-discourse-installation-with-ssl-form-cloudflare/157986 "2020-07-16T22:15:47Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![AntiMetaman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/antimetaman/32/186978_2.png) [@AntiMetaman](https://meta.discourse.org/u/AntiMetaman)
#### Post date: [16 juli 2020 om 22:15 UTC](https://meta.discourse.org/t/502-gateway-error-discourse-installation-with-ssl-form-cloudflare/157986/1 "2020-07-16T22:15:47Z")

</div>

Hi guys,

I’m installing the official Discourse for the first time. I followed the standard instructions: [discourse/docs/INSTALL-cloud.md at main · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md) except I also followed these modifications to my port since port 80 is occupied: [Run other websites on the same machine as Discourse](https://meta.discourse.org/t/running-other-websites-on-the-same-machine-as-discourse/17247)

I changed the exposed ports to 3002:3000. My default directory for where I cloned the git and have all my discourse files is var/www/docker-sites/discourse instead of var/discourse. My app.yml is the same as the standalone.yml in the samples folder except for the change in ports and default directory.  
I am using cloudflare to generate my SSL certificate and key. The details of which are in my etc/nginx/nginx.conf.

I am not migrating any database. This is a fresh install with no users or posts. My VPS has 2 GB of RAM.

I get a 502 gateway error. I’ve tried refreshing. Yes, my DNS records are properly on cloudflare and it is being proxied. The domain is the same as the one in app.yml. I put all my SMTP email info as well in the app.yml correctly. I ran the `./launcher rebuild app` command with no errors. I’m on Ubuntu 20.04.

Any ideas of why I’m getting this 502 gateway error?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [16 juli 2020 om 22:54 UTC](https://meta.discourse.org/t/502-gateway-error-discourse-installation-with-ssl-form-cloudflare/157986/2 "2020-07-16T22:54:10Z")

</div>

It’s impossible to tell, as there are a bunch of ways you could have your reverse proxy broken. And a bunch of ways that moving discourse somewhere other than /var/discourse could make it easy to make a mistake. If you search here, you’ll find dozens of posts about problems caused by cloudflare’s proxying.

You’d be better off starting with something that worked and making one change at a time.

---

<div class="post-metadata">

### Author: ![AntiMetaman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/antimetaman/32/186978_2.png) [@AntiMetaman](https://meta.discourse.org/u/AntiMetaman)
#### Post date: [17 juli 2020 om 00:49 UTC](https://meta.discourse.org/t/502-gateway-error-discourse-installation-with-ssl-form-cloudflare/157986/3 "2020-07-17T00:49:27Z")

</div>

Just wanted to say that I fixed the 502 gateway error. I just needed to restart nginx using `sudo service nginx restart`

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [16 augustus 2020 om 00:49 UTC](https://meta.discourse.org/t/502-gateway-error-discourse-installation-with-ssl-form-cloudflare/157986/4 "2020-08-16T00:49:37Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
