# How to run Discourse as an Apache VirtualHost

**URL:** <https://meta.discourse.org/t/how-to-run-discourse-as-an-apache-virtualhost/154707>\
**Category:** Self-hosting\
**Created:** [12 juni 2020 om 21:37 UTC](https://meta.discourse.org/t/how-to-run-discourse-as-an-apache-virtualhost/154707 "2020-06-12T21:37:36Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![orenwolf](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/orenwolf/32/119529_2.png) [@orenwolf](https://meta.discourse.org/u/orenwolf)\
**Post date:** [6 juli 2020 om 01:41 UTC](https://meta.discourse.org/t/how-to-run-discourse-as-an-apache-virtualhost/154707/8 "2020-07-06T01:41:22Z")

</div>

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:

```plaintext
  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](http://httpd.apache.org/docs/2.4/mod/mod_md.html) that can get your LetsEncrypt certificates for you automatically. I highly recommend it.

---

_[View the full topic](https://meta.discourse.org/t/how-to-run-discourse-as-an-apache-virtualhost/154707)._
