How to run Discourse as an Apache VirtualHost

Two quick additions:

  1. If you’d like to use a unix socket instead of a direct proxy, you can do that (after enabling the web.socketed.template.yml in your app.yml) thusly:
  ProxyPreserveHost On
  ProxyRequests Off
  RequestHeader set X-Forwarded-Proto https
  RequestHeader set X-Real-IP expr=%{REMOTE_ADDR}
  <Location />
    ProxyPass unix:/var/discourse/shared/standalone/nginx.http.sock|http://localhost/
    ProxyPassReverse unix:/var/discourse/shared/standalone/nginx.http.sock|http://localhost/
  </Location>

Note you will probably need to deal with selinux if you try and have apache read from /var/discourse like that. Something like semanage fcontext -a -t httpd_sys_rw_content_t /var/discourse/shared/standalone/nginx.http.sock follwed by a restorecon /var/discourse/shared/standalone/nginx.http.sock should do you for that.

  1. Apache has the rather awesome mod_md that can get your LetsEncrypt certificates for you automatically. I highly recommend it.