502 Gateway Error: Discourse Installation with SSL form Cloudflare

Hi guys,

I’m installing the official Discourse for the first time. I followed the standard instructions: 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: Running other websites on the same machine as Discourse

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?

1 Like

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.

1 Like

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

3 Likes

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