Run other websites on the same machine as Discourse

The guide in the first post is great and, on the whole, still works just fine :sunny:

There are three things worth noting:

  1. I initially missed some of the app.yml changes. There are 3 things you need to change in your app.yml. If you miss any of these things it won’t work:

    1. Comment out all ssl templates in the templates. If you are using letsencrypt you will have two:
      # - "templates/web.ssl.template.yml"
      # - "templates/web.letsencrypt.ssl.template.yml"
      
    2. Add a socket template:
      - "templates/web.socketed.template.yml" 
      
    3. Comment out all exposed ports:
      # - "80:80"   # http
      # - "443:443" # https
      
  2. As others mentioned, I had to change the ssl cert and key names in the discourse.conf:

    ssl_certificate      /var/discourse/shared/standalone/ssl/discourse.angusmcleod.com.au.cer;
    ssl_certificate_key  /var/discourse/shared/standalone/ssl/discourse.angusmcleod.com.au.key;
    
  3. Turns out my site didn’t have a dhparams.pem key (dh stands for Diffie Hellman, there’s some good explanations of what this is here). You can generate this yourself:

    openssl dhparam -out /var/discourse/shared/standalone/ssl/dhparams.pem 2048
    

Some other things you may find useful:

  • sudo netstat -tulpn: This will tell you what ports are being used

  • /var/log/nginx/error.log: Is the location of the nginx log on ubuntu. This will tell you what the error is when you get a 502 Bad Gateway error.

  • You may finish a ./launcher rebuild app, excitedly go to your domain to see if it worked and be greeted with a depressing 502 Bad Gateway error. Before giving up in frustration, try restarting nginx one more time:

    sudo service nginx restart

    This clinched it for me.

Now my sandbox is using nginx outside the container (although I haven’t added the extra website yet).

36 Likes